For these problems you do not need to write entire Matlab functions or scripts,
ID: 3815604 • Letter: F
Question
For these problems you do not need to write entire Matlab functions or scripts, just the condition statements requested. la. Write a selection statement that will print 'warm' if the temperature is between 80 and 90, inclusive. lb. Write a selection statement that will print 'hot' if the temperature >=80, 'pleasant' if the temperature >= 60, 'cool' if the temperature is >=45, 'cold' otherwise. 1c. If integer variable currentNumber is odd, change its value so that it is now 3 times currentNumber plus 1, otherwise change its value so that it is now half of currentNumber 1 d. Find the largest of three scalar numbers x y and z and assign the value to the variable largest.Explanation / Answer
1a.
if temparature<=90 && temparature>=80
disp('warm');
end
1b. nested if else,for every if-else should have end key word
if temparature>=80
disp('hot')
else
if temparature<=60
disp('Pleasent');
else
if temparature<=45
disp('cold');
end
end
end
1c.
if mod(currentNumber,2)!=0 %modulo function it returns remainder of number when divided by 2w
currentNumber=(3*currentNumber)+1;
else
currentNumber=(currentNumber/2);
end
disp(currentNumber);
1d.
largest=max([x,y,z])%max followed by [] and keywowwwwwrdw max ill return largest value