필터 지우기
필터 지우기

How do i extract values from a name-value pair argument?

조회 수: 1 (최근 30일)
AUWAL ABUBAKAR
AUWAL ABUBAKAR 2018년 4월 2일
댓글: AUWAL ABUBAKAR 2018년 4월 3일
Can someone help me on this please. my function is this; fid=fopen('20160613.XVI'); C=textscan(fid,'%s%s','CollectOutput',true,'Delimiter',';'); data=C{1}(71:73,1); [~]=fclose(fid);
It returns the following; {'CouchShiftLat=-0.17' } {'CouchShiftLong=-0.08' } {'CouchShiftHeight=-0.09'} But i needed only the values; -0.17,-0.08 and -0.09.
  댓글 수: 3
AUWAL ABUBAKAR
AUWAL ABUBAKAR 2018년 4월 2일
I am now able to read the values i wanted using the function below:
fid=fopen('20160613.txt');
C=textscan(fid,'%s%s','CollectOutput',true,'Delimiter',';=');
celldata=C{1}(73:75,2);
data=str2double(celldata)
[~]=fclose(fid);
My next task now is to read this from multiple files(1,2...n). Attached here is a sample of my data file.
many thanks

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2018년 4월 2일
files = dir('*.txt') ; % Get all text files of the folder
N = length(files) ; % Total files
% loop for each file
for i = 1:N
file = files(i).name ;
% do what you want
end
  댓글 수: 3
Stephen23
Stephen23 2018년 4월 2일
편집: Stephen23 2018년 4월 2일
"the 'name' meaning the name of the folder or the files in the folder?"
dir returns a structure. One of the fields of that structure is called name: it contains the names of the files/folders. Read more here:
Note that it is good habit to avoid length entirely, and only numel and size.
AUWAL ABUBAKAR
AUWAL ABUBAKAR 2018년 4월 3일
It works perfectly. Thanks a million

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by