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

Make a matlab program to convert units of temperature according to the option th

ID: 3741980 • Letter: M

Question

Make a matlab program to convert units of temperature according to the option that the user chooses and the temperature value that the user also decides. Ask the temperature value, in which units it is and what other unit wants to convert it. The formulas to use are: 2. Haga un programa para convertir unidades de temperatura de acuerdo con la opción que el usuario escoja y el valor de temperatura que también el usuario decida. pregunte el valor de temperatura, en que unidades esta y a que otra unidad la desea convertir. Las formulas a usar son: C = K-273.15 F9K-273.15) sor-32) |K= 5(F-32) + 273.15 K = C + 273.15

Explanation / Answer

function tem()

x = input('Enter the input scale(C, F, K): ','s');

y = input('Enter the output scale(C, F, K): ','s');

x=lower(x);

y=lower(y);

if strcmp(x,y)==1

fprintf('Incorrect input ');

return

elseif ~(strcmp(x,'c')==1 || strcmp(x,'f')==1 || strcmp(x,'k')==1)

fprintf('Incorrect Input ');

elseif ~(strcmp(y,'c')==1 || strcmp(y,'f')==1 || strcmp(y,'k')==1)

fprintf('Incorrect Input ');

else

q = input('Enter the temperature: ');

if(strcmp(x,'c'))

if(strcmp(y,'f'))

t = 9 * q / 5 +32;

fprintf('%d ',t);

elseif(strcmp(y,'k'))

t = q + 273.15;

fprintf('%d ',t);

end

end

if(strcmp(x,'f'))

if(strcmp(y,'c'))

t = 5*(q-32)/9;

fprintf('%d ',t);

elseif(strcmp(y,'k'))

t = 5*(q-32)/9 + 273.15;

fprintf('%d ',t);

end

end

if(strcmp(x,'k'))

if(strcmp(y,'c'))

t = q-273.15;

fprintf('%d ',t);

elseif(strcmp(y,'f'))

t = 9*(q-273.15)/5+32;

fprintf('%d ',t);

end

end

end

This is the whole code for the matlab function. I have used input for input of x and y which are the input and output temperature scales and q for input of temperature. Then I checked for incorrect input and then used a bunch of if elseif else statements and calculations to show the output.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote