How can I create multiple figures in a loop?
显示 更早的评论
I'm trying to plot graphs of the same variables from multiple files. The code below just gives me the same graph five times. How do I get the loop to plot a new figure for each different file?
files=dir('s*.mat');
for i=1:length(files)
load (files(i).name)
end
for i=1:length(files)
figure(i)
plot(data.time,data.s)
hold on
end
采纳的回答
更多回答(1 个)
Walter Roberson
2013-11-8
0 个投票
Each time you are load()'ing a file, you are overwriting the previous "data" variable.
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!