Question

Help! Must program through matlab. Just a bit confused




PRINT HERE HIS PRINTER IS CYBERLOFT The speed of sound depends on the temperature according to the following table Speed of sound (v (m/s) 331 +0.61 332 +0.5*T 333+0.4*T 334+0.3*T 335 +0.2T 336 +0.1*T Temperature (T) (Celsius degrees) 1 Less than 10 10 to less than 20 20 to less than 30 30 to less than 40 40 to less than 50 Over Write an M-file that when executed will request the temperature to be entered in dollars (Celsius) and will display the speed of sound on the command window. Demonstrate your program with the following 5 temperatures and present the M-file and the command window containing all inputs and speed results. 2.5 Celsius 14.5 Celsius 39.5 Celsius 42.25 Celsius 70.5 Celsius
0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB Code:

T = input('Enter temperature: ');
if T < 10
v = 331 + 0.6*T;
else
if T < 20
v = 332 + 0.5*T;
else
if T < 30
v = 333 + 0.4*T;
else
if T < 40
v = 334 + 0.3*T;
else
if T < 50
v = 335 + 0.2*T;
else
v = 336 + 0.1*T;
end
end
end
end
end
fprintf('Speed of sound: %.4f\n', v);

Output:

Enter temperature: 2.5
Speed of sound: 332.5000

Enter temperature: 14.5
Speed of sound: 339.2500

Enter temperature: 39.5
Speed of sound: 345.8500

Enter temperature: 42.25
Speed of sound: 343.4500

Enter temperature: 70.5
Speed of sound: 343.0500

Add a comment
Know the answer?
Add Answer to:
Help! Must program through matlab. Just a bit confused PRINT HERE HIS PRINTER IS CYBERLOFT The...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT