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일

1 개 추천

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

Elysi Cochin
Elysi Cochin 2013년 3월 4일
thank u so much....
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.
I think it should rather be:
exist('A', 'var')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Variables에 대해 자세히 알아보기

질문:

2013년 3월 4일

댓글:

2019년 4월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by