How to populate tiles using the next tile command with a variable number of data and a variable number of plots
12 ビュー (過去 30 日間)
古いコメントを表示
I would like to prepare a code where I can populate tiles using the next tile command with a variable number of data and a variable number of plots using a for loop routine based on the number of variables. For example, here I have prepared displacement, velocity and acceleration of 3 different data sets and I was able to plot them in each individual tile. But the problem is that I had to do this manually instead of doing it with a for loop routine which I can enter the information of not only 3 variables but more variables and have the next tile code simply do it automatically for you without having to enter manually the number of variables.

0 件のコメント
採用された回答
Mathieu NOE
2025 年 9 月 17 日
hello
seems to me the question is more about how to prepare / concatenate your individual data -
either something very simple and basic like below or better use structures or cell arrays (maybe you already use it in your code)
% create some dummy data
nb_vars = 3 ; % accel / vel / displ
n = 5; % how many channels / data per variable
samples = 100;
x = linspace(0,samples)';
for k=1:n
accel(:,k) = sin(x/k+1)+k;
vel(:,k) = cos(x/k+2)-k;
disp(:,k) = -sin(x/k+3)*k;
leg{k} = ['channel ' num2str(k)];
end
%% main code
% Create layout and plots
for ii = 1:nb_vars
if ii == 1
data = accel;
titl = 'Accel';
elseif ii == 2
data = vel;
titl = 'Velocity';
elseif ii == 3
data = disp;
titl = 'Displ';
end
nexttile
plot(x,data)
title(titl)
legend(leg)
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Uncertainty Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
