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

採用された回答

David K.
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 ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by