Effacer les filtres
Effacer les filtres

if condition in the case where char is empty

12 vues (au cours des 30 derniers jours)
Alberto Acri
Alberto Acri le 25 Juin 2023
Hi! I generated an empty char:
name = '';
I should create an if-end of the following type:
if % name is empty
name = 'no name';
end
How to write in Matlab 'if name is empty'?

Réponse acceptée

Mrinal Anand
Mrinal Anand le 25 Juin 2023
You can use the isempty() function in Matlab to accomplish your task:
name = ''; % empty char variable
if isempty(name)
name = 'no name';
end
This will get you the desired result.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by