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 个评论
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