Use MATLAB in all problems and be sure to use suitable MATLAB variable names. 1.
ID: 641713 • Letter: U
Question
Use MATLAB in all problems and be sure to use suitable MATLAB variable names.
1. Write a program which will take either FEWW category or wind speed (in Mi/Hr) as input from the user and respond with a) Safir-Simpson Hurricane category and b) storm surge (in ft). Your program should include Tropical storm & Tropical depression classifications by wind speed. Use the chart below. Your program should take the wind speed or FEWW input, verify the input is correctly specified and free of errors and then produce all of the outputs. The program should be able to accept upper and lower case inputs. E.g. 4A and 4a. If the input is incorrect an error should be displayed and the program terminated.
Hints:
1. It is possible to input character strings with the input command by using ,
Explanation / Answer
FEWW={'1','2A','2B','3A','3B','3C','4A','4B','4C','4D','5'};
safir_simpson=[1,2*ones(1,2),3*ones(1,3),4*ones(1,4),5];
wind_speed=[119,153,154,168,169,177,178,193,194,203,204,209,210,226,227,237,238,244,245,249];
a=input('enter 1 for FEWW category as input or enter 2 for wind speed as input ');
switch a
case 1
b=input('enter FEWW category : ','s');
b=upper(b);
c=find(strcmp(FEWW,b)==1);
if isempty(c)
disp('wrong input,try again');
else
fprintf(' in safir_simpson scale, the rating is %d ',safir_simpson(c));
end
case 2
b=input('enter the wind speed ');
if b<119
disp('wrong input,try again');
else if b>=250
disp('safir simson rating is 5');
else
for i=1:10
if b>=wind_speed(2*i-1) && b<=wind_speed(2*i)
fprintf(' in safir_simpson scale, the rating is %d ',safir_simpson(i));
break;
end
end
end
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.