Time-variying Map with Slider

1 view (last 30 days)
Murat Bektasoglu
Murat Bektasoglu on 25 Mar 2022
Answered: Kevin Holly on 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?

Answers (1)

Kevin Holly
Kevin Holly on 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 = [];
For slider callback:

Community Treasure Hunt

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

Start Hunting!