How to populate tiles using the next tile command with a variable number of data and a variable number of plots
조회 수: 13 (최근 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!
