Why am I getting this error "Operands to the || and && operators must be convertible to logical scalar values."

조회 수: 1 (최근 30일)
function ThCond
alloy = input('Enter the type of metal alloy:', 's');
T = input('Enter temperature(K) to calculate thermal conductivity:','s');
switch alloy
case 'Al2'
if (298 <= T) && (T <= 840)
k = 149.7+0.0809*T-(1*10^(-4))*(T^2);
fprintf('\nThe thermal conductivity(k_s) is $%6.2f\n', k')
elseif (298 <= T) && (T <= 773)
k = 76.64 + 0.2633*T - (2*10^(-4))*(T^2);
fprintf('\nThe thermal conductivity(k_s) is $%6.2f\n', k')
else
disp('Invalid Temperature Input!');
end
end
end

채택된 답변

Star Strider
Star Strider 2018년 4월 18일

Delete the 's' from the temperature input. You want a number, not a string.

T = input('Enter temperature(K) to calculate thermal conductivity: ');

Then it works.

추가 답변 (1개)

Porgs
Porgs 2018년 4월 18일
Thank you

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by