Processing each data automatically in a loop
2 ビュー (過去 30 日間)
古いコメントを表示
Ritesh Chandra Tewari
2022 年 10 月 11 日
コメント済み: Ritesh Chandra Tewari
2022 年 10 月 12 日
for i=0:287
c = '.dat';
i=int2str(i);
str = append(i,c);
[filename,pathname] = uigetfile(str);
fileID = fopen(filename, 'r');
dataArray = textscan(fileID, '%f');
fclose(fileID);
radarData = dataArray{1};
clearvars fileID dataArray ans;
"data processing part"
end
I have 288 data in .dat format naming like 0.dat, 1.dat, 2.dat,............,287.dat,288.dat. When I run the above code, a popup window appears to select the dataevery time loop runs. How to automate the data selection process?
0 件のコメント
採用された回答
Jan
2022 年 10 月 11 日
編集済み: Jan
2022 年 10 月 11 日
If you do not want to call uigetfile, remove this command:
pathname = 'C:\Your\Folder';
for i = 0:287
filename = fullfile(pathname, sprintf('%d.dat', i));
[fileID, msg] = fopen(filename, 'r');
assert(fileID > 0, msg);
dataArray = textscan(fileID, '%f');
fclose(fileID);
radarData = dataArray{1};
% Omit this, because it has no benefits: clearvars fileID dataArray ans;
% Most of all clearing "ans" is a waste of time only.
"data processing part"
end
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!