Effacer les filtres
Effacer les filtres

how to write empty variable....

150 vues (au cours des 30 derniers jours)
Elysi Cochin
Elysi Cochin le 4 Mar 2013
Commenté : Nikolay le 24 Avr 2019
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...

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Debugging and Analysis dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by