Dir function with no file extension
16 ビュー (過去 30 日間)
古いコメントを表示
Dear communtiy.
I am using a script with the dir function as shown below but my question is I do not know what the data type of my file is. It has no description as ' data1.doc' It is just named as 'data1' and this continues to 'data40'. I have put several other files in the folder and it works. But it doesn't show the files that I want.
I have searched the community with file processing with no extension but coudn't find any.
I hope you guys can help me out
matFiles = dir('*.') ; % open certain files in the folder.%
N = length(matFiles) ;
for i = 1:N
load(matFiles(i).name) ; %
frequency = data(:,1);
zabsolute = data(:,2);
degree = data(:,3);
x= frequency * 1000; %% frequency is given in KHz multiply with 1000
y1 = zabsolute .* cosd(degree); %% formula to calculate the imaginair component of impedance
y2 = zabsolute .* sind(degree); %% formula to calculate the real component of impedance
figure(i)
subplot(2,1,1);
plot(x,y1),
title ( ' Resistance ' );
xlabel ( ' Frequency (Hz)');
ylabel ( ' Re Z');
subplot (2,1,2);
plot (x,y2);
title ( ' Reactance' );
xlabel ( ' Frequency (Hz)');
ylabel ( ' Img Z')
end
1 件のコメント
Stephen23
2021 年 3 月 3 日
編集済み: Stephen23
2021 年 3 月 3 日
"It has no description as ' data1.doc' It is just named as 'data1' and this continues to 'data40'."
If you are using MS Windows, have you turned off the folder setting which hides known file extensions?
Many MS Windows users are tricked by this awful, counter-helpful, badly-thought-out default setting, because they think that their files have no file extensions, whereas in fact Windows just hides them.
採用された回答
Stephen23
2021 年 3 月 3 日
Try specifying the fixed part of the filename:
S = dir('Data*')
and/or removing folder from the output:
S = dir('*');
S = S(~[S.isdir]);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!