I tried to read to .txt files in Matlab that include monthly information about solar radiation and temperatures. The months are as text i.e Jan, Feb, etc. Then with this information need to make some graphs to display the information per month, like for example monthly solar radiation having the months in the x-axis. Beyond that need to plot two graph on the same figure since I have Matlab 2015b need to use plotyy. THE PROBLEM: I thought that the months were correct read from the file, but when I plot takes all the months as January so I cannot plot correctly two graphs since the times are different.
The code that using is:
fidata = fopen('Asmara-mon2.txt', 'r' );
formatSpeci = '%s';
N1 = 9;
% h1=('Month' 'Temp' 'Tamin' 'Tadmin' 'Tadmax' 'Tamax' 'RH');
h3 = textscan(fidata,formatSpeci,N1,'Delimiter','|');
asmara_precipitation= textscan(fidata,'%{MM}D %f %f %f %f %f %f %f %f');
% formatIn = 'mm';
asmara_precipitation{1}=datenum(asmara_precipitation{1});
asmara_precipitation=cell2mat(asmara_precipitation); %% Month| H_Gh| SDm |SDd|SDastr |RR |RD |FF |DD
[MonthNum, MonthString] = month(asmara_precipitation(:,1));
p=find(average_day_radiation(:,1)<10);
q=find(diff(p)==1);
idx=[p average_day_radiation(p) average_day_radiation(p,2) average_day_radiation(p,4)];
consecutive_idx=[p(q) idx(q,2) idx(q,3) idx(q,4)];
% Graphic of bad radiation days
figure (44)
hold on
plotyy(MonthNum,asmara_precipitation(:,7),consecutive_idx(:,1),consecutive_idx(:,2))
datetick('x','mmm')
Thank you in advance for any help and sorry to ask something that could seem silly.