MATLAB: MATLAB SWITCH not recognizing string from Excel spread sheet

excelimporting excel datastringsswitch

Hi everyone,
I've been getting input from an Excel file and I want to use a SWITCH expression based on the selections. MATLAB gives the following error: SWITCH expression must be a scalar or string constant. My code looks like this:
a = excelInput;
switch a
case 'velocity'
% do something
case 'time'
% do something else
end

Best Answer

Try
switch a{1}