Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

check value in matfile

Asked by Elysi Cochin on 29 Dec 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...

0 Comments

Elysi Cochin

Tags

Products

No products are associated with this question.

1 Answer

Answer by Matt J on 29 Dec 2012
Edited by Matt J on 29 Dec 2012
Accepted answer
   S=load(filename,'tval');
   if ismember(4,S.tval),
    disp 'yes'
   else
    disp 'no',
   end

3 Comments

Elysi Cochin on 31 Dec 2012

sir i'm getting error... its saying undefined function 'filename'

Walter Roberson on 31 Dec 2012
S=load('filename','tval');
Elysi Cochin on 31 Dec 2012

thank u sir...

Matt J

Contact us