How to populate tiles using the next tile command with a variable number of data and a variable number of plots
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
juan sanchez
el 17 de Sept. de 2025
Comentada: juan sanchez
el 26 de Oct. de 2025 a las 5:22
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 comentarios
Respuesta aceptada
Mathieu NOE
el 17 de Sept. de 2025
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
Más respuestas (0)
Ver también
Categorías
Más información sobre Uncertainty Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
