Time-variying Map with Slider

22 次查看(过去 30 天)
Murat Bektasoglu
Murat Bektasoglu 2022-3-25
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?

回答(1 个)

Kevin Holly
Kevin Holly 2022-4-29
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)

类别

Help CenterFile Exchange 中查找有关 Live Scripts and Functions 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by