Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

y 46. Swtch statement Write A Switch s://learn 02Fall2017Ichapter/4/section/6 YE

ID: 3889783 • Letter: Y

Question

y 46. Swtch statement Write A Switch s://learn 02Fall2017Ichapter/4/section/6 YEGR GR 102 home> 4.6: Switch Preset rpm speeds A centrituge has tour preset speeds. Write a switch statement that assigns rpmSetting with the appropriate rpm speed given preservalue. it the presetValue does not match any of the preset values defined, then assign pmSetting with o Setting RPM 1 3500 2 6125 3 9000 Ex: If presetValue is 1, then rpmSetting is 3500 Your Function Save Reset MATLAB Documentation function rpmSetting SetCentrifugeSpeed(presetVatue write a switch statement to assign rpnsetting with the appropiate value given prese tvalue rpnSet ting e; 7 end Code to call your function C Reset : SetcentrifugeSpeed(1) MacBook Air

Explanation / Answer

function rpmSetting = SetCentrifugeSpeed(presentValue)

% switch case to return a rpm setting for a given present value

switch presentValue

case 1

rpmSetting = 3500;
  
case 2
  
rpmSetting = 6125;
  
case 3
  
rpmSetting = 9000;
  
otherwise
  
rpmSetting = 0;

end

end

disp(SetCentrifugeSpeed(1));
disp(SetCentrifugeSpeed(2));
disp(SetCentrifugeSpeed(3));
disp(SetCentrifugeSpeed(4));

% sample output
% 3500
% 6125
% 9000
% 0