Time-variying Map with Slider

20 Ansichten (letzte 30 Tage)
Murat Bektasoglu
Murat Bektasoglu am 25 Mär. 2022
Beantwortet: Kevin Holly am 29 Apr. 2022
Hello. I have a dataset that changes over time. I am using this dataset to make a world map. What I want to do is instant change of the map created using a slider. After creating my data as below, I want to exchange this data with the dates they represent on the slider.But in the meantime, I couldn't figure out how to handle the dates in the slider bar. If I get the date value from the Slider bar, it will be very easy to associate it with the data of that date. Will you help me with this problem?

Antworten (1)

Kevin Holly
Kevin Holly am 29 Apr. 2022
Place these commands in callback after loading the data_struct variable
% Convert structural array, data_struct, into a table
t = struct2table(data_struct);
% Read dates from table heading
dates = t.Properties.VariableNames;
% Convert to datetime
dates = datetime(dates,"Format","MMMMuuuu");
% Change datetime format
dates = datetime(dates,"Format","MMM-uuuu");
app.Slider.Limits = [1, length(dates)];
% app.Slider.MajorTicks = 1:1:length(dates);
% app.Slider.MajorTickLabels = string(dates);
app.Slider.MajorTicks = 1:5:length(dates); % you can adjust the increment to best suit your data
app.Slider.MajorTickLabels = string(dates(1:5:end));
app.Slider.MinorTicks = [];
imshow(data_struct.(t.Properties.VariableNames{app.Slider.Value}),"Parent",app.UIAxes)
For slider callback:
imshow(data_struct.(t.Properties.VariableNames{app.Slider.Value}),"Parent",app.UIAxes)

Kategorien

Mehr zu Live Scripts and Functions finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by