Question about making a 4-line if statement into a single line
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
N/A
am 26 Okt. 2022
Kommentiert: KALYAN ACHARJYA
am 26 Okt. 2022
hello
first, here is my code
A=rand;
if A > 0.5
disp([num2str(A), ' ', 'Great indeed!'])
end
This is a code that generates a random number with 'rand' command and outputs 'Great indeed!' text if the value exceeds 0.5.
I want to make the code in single line but i have no idea.
Should I use 'switch' command or is there any better way?
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!