MATLAB Answers


how to write empty variable....

Asked by Elysi Cochin on 4 Mar 2013
Latest activity Commented on by Abdul Rehman Akbar on 10 Apr 2014

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...



No products are associated with this question.

1 Answer

Answer by ChristianW
on 4 Mar 2013
 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


thank u so much....

Thank You very much. I was searching this command. your answer is very useful for me.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
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

MATLAB Academy

New to MATLAB?

Learn MATLAB today!