Unable to plot multiple graphs using a loop, only plots final graph

4 ビュー (過去 30 日間)
Luke Riddell
Luke Riddell 2020 年 8 月 19 日
回答済み: KSSV 2020 年 8 月 19 日
I'm trying to extract data from files to create individual plots - one for each of the files. However with my following code, it only plots what I believe is the final graph, and not any of the others. Each file contains 25 lines of headers then has values separated by the 'tab' delimiter.
for i = 1:28
fid = fopen(ASCname{i},'r'); %ACSname is a cell containing the names of the files
d= textscan(fid,'%f%f','HeaderLines',25);
plot(d{1},d{2})
xlabel('Wavenumber / cm^-^1')
ylabel('Absorbance')
fclose(fid);
end
Without using the loop (ie. by copying the section of code in the loop and simply iteratively increasing the index) yields multiple graphs but this is not only horribly ugly code but is completely impractical for my large dataset.
I'm stuck - please help!

採用された回答

KSSV
KSSV 2020 年 8 月 19 日
for i = 1:28
fid = fopen(ASCname{i},'r'); %ACSname is a cell containing the names of the files
d= textscan(fid,'%f%f','HeaderLines',25);
figure(i)
plot(d{1},d{2})
xlabel('Wavenumber / cm^-^1')
ylabel('Absorbance')
fclose(fid);
enda

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeApp Building についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by