use the if-else loop considering a variable 'char' in the workspace
    1 view (last 30 days)
  
       Show older comments
    
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 Comments
Accepted Answer
  Dyuman Joshi
      
      
 on 1 Dec 2023
        
      Edited: Dyuman Joshi
      
      
 on 1 Dec 2023
  
      out = 'analysis';  % or number
if ischar(out)
    disp('character')
elseif isnumeric(out)
    disp('numeric data')
else
    disp('Unknown data')
end
0 Comments
More Answers (0)
See Also
Categories
				Find more on Loops and Conditional Statements in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!