Al momento, stai seguendo questo contributo
- Vedrai gli aggiornamenti nel tuo feed del contenuto seguito
- Potresti ricevere delle email a seconda delle tue preferenze per le comunicazioni
shortcut for simple if conditions.
The function works similar to Excel format.
First argument is the condition, second is what to do if true, third is what to do if false.
example 1:
A = ifelse(x>thr, 5, 3)
will execute:
if x>thr
A = 5
else
A = 3
end
example 2:
A = ifelse(im>thr, im*2, im/2)
will execute:
A = im*2 where im>thr
A = im/2 where im<=thr
example 3:
ifelse(x~=0, 'y=1/x;', 'disp ''x is zero''')
will execute:
if x~=0
y = 1/x;
else
disp 'x is zero'
end
Cita come
Yanai (2026). if-then-else shortcut (https://it.mathworks.com/matlabcentral/fileexchange/28587-if-then-else-shortcut), MATLAB Central File Exchange. Recuperato .
Informazioni generali
- Versione 1.1.0.0 (1,5 KB)
Compatibilità della release di MATLAB
- Compatibile con qualsiasi release
Compatibilità della piattaforma
- Windows
- macOS
- Linux
