Time-variying Map with Slider

조회 수: 21 (최근 30일)
Murat Bektasoglu
Murat Bektasoglu 2022년 3월 25일
답변: Kevin Holly 2022년 4월 29일
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