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 Center および File ExchangeWorkspace 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