function Plot_Callback(hObject, eventdata, handles)
% hObject handle to Plot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
cla
hold all;
PathName=evalin('base','PathName');
FileName=evalin('base','FileName');
StringEPS=evalin('base','StringEPS');
SelectedELU=evalin('base','SelectedELU');
SelectedVar=evalin('base','SelectedVar');
FileName=sort(FileName);
d='1970-01-01 02:00:00.000'; %define start date of Timecode
t = datetime(d,'InputFormat','yyyy-MM-dd HH:mm:ss.SSS');
for r=1:length(SelectedELU)
PlotData=[];
TimeData=[];
for k=1:length(FileName)
load([PathName FileName{k}]);
y=eval(SelectedELU{r});
i=SelectedVar{1};
yy=y.(i);
PlotData=[PlotData; yy'];
yy=y.SYSTEMTIME;
yy= seconds(yy);
yy=yy(:)/1000;
yy= yy + t;
TimeData=[TimeData; yy];
end
try
Plot(:,r)=PlotData;
Time(:,r)=TimeData;
catch
if length(Plot)>length(PlotData)
a(length(Plot)-length(PlotData),1)=NaN;
b(length(Plot)-length(PlotData),1)=NaT;
PlotData=[PlotData; a];
TimeData=[TimeData; b];
Plot(:,r)=PlotData;
Time(:,r)=TimeData;
elseif length(Plot)<length(PlotData)
PlotData=PlotData(1:length(Plot),1);
TimeData=TimeData(1:length(Plot),1);
Plot(:,r)=PlotData;
Time(:,r)=TimeData;
end
end
end
for r=1:length(SelectedELU)
plot(Time(:,r),Plot(:,r),'DisplayName',StringEPS{r});
end
%assignin('base','PlotData',PlotData)
%assignin('base','TimeData',TimeData)
legend('Location','best')
ylabel(i);
xlabel('Date')
axis 'tight'
zoom on
dcm_obj = datacursormode(gcf);
set(dcm_obj,'DisplayStyle','datatip',...
'SnapToDataVertex','off','Enable','on', ...
'UpdateFcn',{@myupdatefcn})
i fixed the problem some time ago and wanted to complete this thread.
the solution to the problem was to put the plot command outside of the for loop. so i saved all my plot and time data in arrays and plot them in a seperate loop.
i dont know why it works like this and why it doesent work with the original version, but who cares as long as it works...