load multiple mat files for plot
20 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Mohammed
le 12 Mai 2016
Réponse apportée : Guillaume
le 12 Mai 2016
I have a number (n) of mat files saved in one folder, their names are :
data1.mat, data2.mat, data3.mat, data4.mat, data5.mat,......
assume that each mat file has these vectors: t , x, y.
I want to plot t vs. y (saved in the same mat file) in one figure from all these files using for loop in a manner like this|
plot(t,y)---from data1.mat
hold on
plot(t,y)---from data2.mat
plot(t,y)---from data3.mat
.
.
.plot(t,y)---from datan.mat
0 commentaires
Réponse acceptée
Guillaume
le 12 Mai 2016
figure;
hold on;
for fileidx = 1:n
filedata = load(fullfile('C:\location\of\the\files', sprintf('data%d.mat', fileidx)));
plot(filedata.t, filedata.y);
end
would work. As long as you don't want to do anything else with the t and y
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Workspace Variables and MAT Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!