MATLAB Answers

Adjust x-axis using 2 sliders in GUIDE

5 views (last 30 days)
Chamath Vithanawasam
Chamath Vithanawasam on 2 Aug 2018
I want to adjust the maximum and the minimum of a plot using two sliders, or any other alternative to that, the challenge is that the data that is plotted depends on x-axis values which are date and time, a piece of which is shown below. This data spans for months, so there is a lot of information.
DD.MM.YYYY hh:mm:ss;degC;degC
02.01.2018 00:00:16;29.78;30.54
02.01.2018 00:01:18;29.78;30.54
02.01.2018 00:02:19;29.78;30.54
02.01.2018 00:03:16;29.78;30.54
02.01.2018 00:04:18;29.78;30.54
02.01.2018 00:05:19;29.78;30.54
The data for the time along with the temperature readings are saved in a column using the following code format.
f = dir('*.log');
handles.alldatatable = [];
for ii = 1:numel(f)
DayFile = f(ii).name;
opts = detectImportOptions(DayFile);
opts = setvartype(opts,1,'datetime');
opts = setvaropts(opts,1,'InputFormat','dd.MM.uuuu HH:mm:ss');
table1 = readtable(DayFile,opts);
if isempty(handles.alldatatable)
handles.alldatatable = table1;
else
handles.alldatatable = [handles.alldatatable; table1];
end
end
How do I get two sliders to adjust datetime format values, one adjusting the minimum and the other adjusting the maximum points of the time in a plot?

  4 Comments

Show 1 older comment
Chamath Vithanawasam
Chamath Vithanawasam on 3 Aug 2018
No that function only collects data to create a table, the plotting occurs via a pushbutton callback
function pushbutton1_Callback(hObject, eventdata, handles)
a = getappdata(0,'totData');
axes(handles.axes1);
plot((a{:,1}),(a{:,listValueAA+1}));
Jan
Jan on 3 Aug 2018
It is a really bad idea to use the ApplicationData of the root object to store data. This has the same disadvantages as global variables. Use guidata to store the values inside the figure of the GUI.
Chamath Vithanawasam
Chamath Vithanawasam on 3 Aug 2018
Understood, will try and make some changes.

Sign in to comment.

Sign in to answer this question.

Products


Release

R2017b