Dir function with no file extension

조회 수: 9 (최근 30일)
Bayram Akpinar
Bayram Akpinar 2021년 3월 3일
편집: Stephen23 2021년 3월 3일
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
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
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 CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by