Question: Code for MATlab use SB temperature data read by either fgetl, fscanf or textscan and plot with waterfall temperature data should be resaved in matrix
Code for MATlab
use SB temperature data read by either fgetl, fscanf or textscan and plot with waterfall temperature data should be resaved in matrix
modify the waterfall plot to 50% transparency by setting FaceAlpha=0.5 modify the line width to 2
add axes label and title
add axes tick label with month info
add text to show each temperature info by using figure tool box
You can customize the graph more! - change font size, add marker, change colormap, etc submit the codes in script file named MyWaterFall.m, and graph in jpg format
also the txt file is this:
ave.temp ave.high.temp ave.low.temp highest.rec.temp lowest.rec.temp
Jan 31.60 38.60 24.60 69.00 -4.00
Feb 31.70 39.20 24.30 69.00 -11.00
Mar 39.00 47.10 31.10 83.00 7.00
Apr 48.90 58.20 39.70 95.00 15.00
May 58.90 68.70 49.20 95.00 30.00
Jun 67.80 76.90 58.60 96.00 36.00
Jul 73.10 81.70 64.50 99.00 48.00
Aug 71.90 79.90 63.90 100.00 44.00
Sep 66.00 73.80 58.10 96.00 36.00
Oct 56.10 64.00 48.10 91.00 26.00
Nov 46.00 53.40 38.70 81.00 14.00
Dec 35.70 42.50 29.00 75.00 -7.00
I've tried to use textscan but I'm not sure how to put it all together.
Here's my code as of now:
myfile=uigetfile; fid=fopen(myfile); if fid==-1 disp('File not available'); myfile=input('Choose another file: ','s'); fid=fopen(myfile); end month=1:12; header=textscan(fid,'%s%s%s%s%s '); avgtemp=header{1}; avghigh=header{2}; avglow=header{3}; highesttemp=header{4}; lowesttemp=header{5}; data=textscan(fid,'%s%f%f%f%f%f'); month=data{1}; ave.temp=data{2}; ave.high.temp=data{3}; ave.low.temp=data{4}; highest.rec.temp=data{5}; lowest.rec.temp=data{6}; [r,c]=size(data); X=[ave.temp,ave.high.temp,ave.low.temp,highest.rec.temp,lowest.rec.temp]; Y=month; Z=header; tempmat=mat(X,Y,Z);
figure
waterfall(tempmat) tempmat.FaceAlpha=0.5; tempmat.LineWidth=2; colormap(cool) xlabel=('Month'); ylabel=('Temp Data'); zlabel=('Temp(F)'); xticks=(1:12); xticklabels({'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'}) title('SB Monthly Temperature Data') lim([min((lowest.rec.temp)-10),max((highest.rec.temp)+10),1,12])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
