how to write empty variable....

150 次查看(过去 30 天)
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...

采纳的回答

ChristianW
ChristianW 2013-3-4
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 个评论
Abdul Rehman Akbar
Abdul Rehman Akbar 2014-4-10
Thank You very much. I was searching this command. your answer is very useful for me.
Nikolay
Nikolay 2019-4-24
I think it should rather be:
exist('A', 'var')

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Debugging and Analysis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by