【for文】txt.インポートとの併用は可能か
2 views (last 30 days)
Show older comments
添付した「test...2225.m」のように、現在10000行2列のtxt.のデータインポートをし、グラフをプロットしている者です。
毎回11個のファイルをいちいち書き出すのは面倒と感じています。
そこでtxt.に番号を振り分け(添付したPNGファイルのように)、以下のようにforループにすれば良いと考えたのですが、うまく行かない模様です。
インポートされたファイルはfor文に入れられないのでしょうか。
import用のファイルも添付したので、どなたかご協力をお願い致します。
startRow = 1;
endRow = inf;
for n=1:11
[An(:,1),An(:,2)] = importfile('20230829_m_1_n.txt', startRow, endRow);
%
end
figure(1)
plot(A1(:,1),A1(:,2),A2(:,1),A2(:,2),A3(:,1),A3(:,2),A4(:,1),A4(:,2),A5(:,1),A5(:,2),A6(:,1),A6(:,2),A7(:,1),A7(:,2),A8(:,1),A8(:,2),A9(:,1),A9(:,2),A10(:,1),A10(:,2),A11(:,1),A11(:,2)),
legend('0','0.05','0.1','0.15','0.2','0.25','0.3','0.35','0.4','0.45','0.5'),
xlabel('Wauelengthcnm(nm)'), ylabel('Pawer(dBm)'),
0 Comments
Answers (1)
Atsushi Ueno
on 30 Aug 2023
> インポートされたファイルはfor文に入れられないのでしょうか
startRow = 1;
endRow = inf;
for n = 1:11
filename = sprintf('20230829_m_1_%d.txt', n)
% fclose(fopen(filename, 'w')); % 実験用に空ファイルを作成
[An(:,1),An(:,2)] = importfile(filename, startRow, endRow);
end
See Also
Categories
Find more on グラフィックス オブジェクトの識別 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!