How can I use switch case function to get decimal numbers?
Show older comments
M% Temperatur_C = [13,6169 14,5432 15,2356 17,2456 18,1887 19.9874 21,2765]
% Coeff -30C -20 -10 0 10 20 30 40 50
% nT 1.8 1.8 1.4 1.1 1.1 1 0.9 0.9 0.8
for A=1:(a-1)
switch (Temperatur_C(1,A))
case num2cell(-10.0:0)
disp('nT=1.4')
nT_NO(1,A) = 1.4;
case num2cell(0.1:4.99)
disp('nT=1.1')
nT_NO(1,A) = 1.1;
end
If I use round command I get the answer but that's not right for me because I want to be able to get the specific temperature not rounded.For example if the temp is 18,1887 it gets it as 20.
for A=1:(a-1)
switch round(Temperatur_C(1,A))
case num2cell(-10.0:0)
disp('nT=1.4')
nT_NO(1,A) = 1.4;
case num2cell(0.1:4.99)
disp('nT=1.1')
nT_NO(1,A) = 1.1;
end
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with MATLAB 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!