How to plot data from mutiple files in a loop so that all is collated in one figure?

1 vue (au cours des 30 derniers jours)
Hi all,
I have a list of of 11 files which are structures with a table.
I want to access a variable in each table from each file and collate it in one figure.
My approach below results in plotting only one variable, instead of 11. Can you help please?
for k = 1:length(files)
% Load data
A = fullfile(Folder,files(k).name);
data = load(A);
% Plot selected variable from each file in one figure
figure;
plot(data.Cycles.Cop_x_l_meancycle);
hold on
end

Réponse acceptée

KSSV
KSSV le 21 Juil 2022
data = cell(length(files),1) ;
for k = 1:length(files)
% Load data
A = fullfile(Folder,files(k).name);
data = load(A);
% Plot selected variable from each file in one figure
data{k} = data.Cycles.Cop_x_l_meancycle;
end
Now you have all data of files int he cell array data. You can access it, play with it to plot.

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by