How can I use sliders to do interactive plots from a structure array?
古いコメントを表示
I have a structure array containing a B number of matrixes of [MxN] data, where M is different for every set and N is the same for every set of data.
I would like to have only one plot, where using two sliders I can choose between the B sets of data and N columns. I have only found examples of how to use a slider to update a plot changing a parameter (like the damping factor of a sinusoid), but nothing useful for my case.
4 件のコメント
Stijn Haenen
2020 年 8 月 4 日
Something like this:
close all
clear
b=struct;
for i=1:10
b(i).data=ones(10)*i.*(i:i:i*10); %creating struc with data
end
fig = figure;
s1 = uicontrol('Parent',fig,'Style','slider','Position',[81,1,419,23],...
'value',0.1, 'min',0.1, 'max',10);
s2 = uicontrol('Parent',fig,'Style','slider','Position',[81,24,419,23],...
'value',0.1, 'min',0.1, 'max',10); %creating sliders
hold on
while 1>0
plot(b(ceil(s1.Value)).data(:,ceil(s2.Value)),'b') %plot data
pause(0.1)
delete(fig.CurrentAxes.Children)
end
Seth Meiselman
2020 年 9 月 17 日
Could you give an example of this structure array- how you've composed it in code? I think the solution above seems reasonable unless there is something specific about how you've constructed this data set. Are the matrices enumerated or labeled in the structure?
Alessandro Giacetti
2020 年 9 月 17 日
Rik
2020 年 9 月 17 日
If you write code using that callback (and I encourage you to try something yourself), make sure to round the value, as you're not guaranteed an integer.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!