I created an anomaly time series function. I want to plot this in the app designer but I get the following error: Error using plot Data must be numeric, datetime, duration or an array convertible to double. I get this error in the plot section. How can I fix this?
function LoadButton_2Pushed(app, event) lat = app.EpochEditField_4.Value; lon = app.EpochEditField_5.Value; year = app.EpochEditField_3.Value; month = app.EditField_3.Value; day = app.EditField_4.Value; k = datetime(year,month,day); doy = datenum([year,month,day, 0, 0, 0]) - datenum([year, 1, zeros(1, 4)]); yearstr=num2str(year); nn=['CODG' sprintf('%03s',num2str((doy))) '0.' yearstr(3:4) 'I' '.mat']; fid = nn; grid_point=whichGrid(lat,lon,fid); grid_lat=floor(lat/2.5)*2.5; grid_lon=floor(lon/5)*5; d_lat=(lat-grid_lat)/5; d_lon=(lon-grid_lon)/5; whichFile=strsplit(fid,'.'); whichType=(whichFile{1,1}(1:end-4)); load('allMatrix.mat'); %
if whichType == "CODG" files1=all(:,1); elseif whichType == "COPG" files1=all(:,2); elseif whichType == "Anomaly" files1=all(:,3); end totalFiles = numel(files1); for i=1:totalFiles if isequaln(fid,(files1(i).name)) last_day=i; first_day=i-29; end end allTEC=[]; timeser=[]; for k=1:16 del1=[]; del2=[]; del3=[]; del4=[]; for j= first_day-1+k : first_day+13+k dd=load(files1(j).name); del1=[del1 , dd.Ionex.TECU(grid_point(1,1),grid_point(1,2),:)]; del2=[del2 , dd.Ionex.TECU(grid_point(1,1)-1,grid_point(1,2),:)]; del3=[del3 , dd.Ionex.TECU(grid_point(1,1),grid_point(1,2)+1,:)]; del4=[del4 , dd.Ionex.TECU(grid_point(1,1)-1,grid_point(1,2)+1,:)]; end allTEC1(k,:,:)=del1; allTEC2(k,:,:)=del2; allTEC3(k,:,:)=del3; allTEC4(k,:,:)=del4; timeser=[timeser ; dd.Ionex.EpochOfCurrentMap]; end timeser=timeser(1:195,:);% timeser=cell2mat(timeser); for j=1:13 for k=1:16 for i=1:15 allTEC(k,i,j)=[1-d_lon, d_lon ]*[allTEC1(k,i,j), allTEC2(k,i,j); allTEC3(k,i,j) ,allTEC4(k,i,j)]/10*[1-d_lat; d_lat]; end end end formatIn = 'yyyy mm dd HH MM SS'; [Y,M,D,H,Mn,S] = datevec(timeser,formatIn); date_e = datenum(Y,M,D,H,Mn,S); date_e=datestr(date_e); days_mean=mean(allTEC(1:15,:,:));% if whichType=="Anomaly" d16band=2.0*std(allTEC(1:15,:,:)); %
else d16band=1.34*std(allTEC(1:15,:,:)); % end real=allTEC(2:16,15,:); real=permute(real, [2 1 3]); u_l_band=[days_mean + d16band; days_mean - d16band; real]; new=[]; for m=1:13 new=[new u_l_band(:,:,m)]; end new=new/10; [~,col]=size(new); anomaly_time=[]; anomaly_values=[]; for i=1:col if new(3,i)> new(1,i) || new(3,i)< new(2,i) anomaly_time=[anomaly_time ; date_e(i,:)]; anomaly_values=[anomaly_values new(:,i)]; end end ts1=timeseries(new,date_e,'name','Tec Values'); ax=app.UIAxes6; plot(ax,ts1) grid on end
Best Answer