Filter löschen
Filter löschen

if condition in the case where char is empty

10 Ansichten (letzte 30 Tage)
Alberto Acri
Alberto Acri am 25 Jun. 2023
Beantwortet: Mrinal Anand am 25 Jun. 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'?

Akzeptierte Antwort

Mrinal Anand
Mrinal Anand am 25 Jun. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by