Time-variying Map with Slider
조회 수: 21 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (1개)
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)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Live Scripts and Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!