how to write empty variable....

while doing a calculation if i get a variable named "varName" with empty value i wanted to display a message "Dont not Exist"...... how to write a code for checking whether a variable contains value or it is empty... please do reply...

 Accepted Answer

A = [] % A is empty
isempty(A) % Is A empty?
exist(A,'var') % Does A exist as variable?
% empty and not existing isnt the same thing

3 Comments

thank u so much....
Thank You very much. I was searching this command. your answer is very useful for me.
I think it should rather be:
exist('A', 'var')

Sign in to comment.

More Answers (0)

Categories

Asked:

on 4 Mar 2013

Commented:

on 24 Apr 2019

Community Treasure Hunt

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

Start Hunting!