plotting data from data files and saving each plot through out each run of the loop
1 次查看(过去 30 天)
显示 更早的评论
hello guys im trying to plot data from different dat files that have different parameters C (used to identity the file) throghout each run of the loop. For some reason im only getting one plot. Please help
below is what i did.
******************************************************************************************
Cpara=[0.02, 0.03, 0.04, 0.05, 0.06, 0.015, 0.025, 0.035, 0.045, 0.055];
for k = Cpara
file = importdata(strcat('A=0.12_B=2_C=',mat2str(k),'_hnull_2.1_t0.01e.dat'));
plot(file(:,1),file(:,2))
end
0 个评论
采纳的回答
David K.
2019-9-12
If you wish to have all the plots on the same figure, you need to use
figure;
hold on
%The rest of your code
If you wish to have multiple figures you need to do
for k = Cpara
file = importdata(strcat('A=0.12_B=2_C=',mat2str(k),'_hnull_2.1_t0.01e.dat'));
figure
plot(file(:,1),file(:,2))
end
What you were doing was just replacing each plot with the next one instead of creating new figures.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!