check value in matfile

2 vues (au cours des 30 derniers jours)
Elysi Cochin
Elysi Cochin le 29 Déc 2012
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...

Réponse acceptée

Matt J
Matt J le 29 Déc 2012
Modifié(e) : Matt J le 29 Déc 2012
S=load(filename,'tval');
if ismember(4,S.tval),
disp 'yes'
else
disp 'no',
end
  3 commentaires
Walter Roberson
Walter Roberson le 31 Déc 2012
S=load('filename','tval');
Elysi Cochin
Elysi Cochin le 31 Déc 2012
thank u sir...

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by