check value in matfile

조회 수: 2 (최근 30일)
Elysi Cochin
Elysi Cochin 2012년 12월 29일
I created a matfile as below..
tval=[1 2 3 4 5 6 7]
save filename tval;
now i have a variable whose value is 4...
now i want to check whether that value contains in the matfile... if it is there i want to display a message 'yes' and if not there display 'no'...
please can someone show me how to check whether the variable's values is in the matfile or not...

채택된 답변

Matt J
Matt J 2012년 12월 29일
편집: Matt J 2012년 12월 29일
S=load(filename,'tval');
if ismember(4,S.tval),
disp 'yes'
else
disp 'no',
end
  댓글 수: 3
Walter Roberson
Walter Roberson 2012년 12월 31일
S=load('filename','tval');
Elysi Cochin
Elysi Cochin 2012년 12월 31일
thank u sir...

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by