use the if-else loop considering a variable 'char' in the workspace
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alberto Acri
el 1 de Dic. de 2023
Editada: Dyuman Joshi
el 1 de Dic. de 2023
Hi! I have an 'out' variable in the workspace that can be a number or a char. How can I use the if-else loop considering this variation of the variable 'out'?
For example:
out = 'analysis'; % or number
if out % 'out' is char
text = out;
else % 'out' is number
% ....
end
0 comentarios
Respuesta aceptada
Dyuman Joshi
el 1 de Dic. de 2023
Editada: Dyuman Joshi
el 1 de Dic. de 2023
out = 'analysis'; % or number
if ischar(out)
disp('character')
elseif isnumeric(out)
disp('numeric data')
else
disp('Unknown data')
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!