Please help to solve this
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
The following is an approximate conversion formula for converting Fahrenheit to Celsius:
Celsius≈(Fahrenheit-30)/2
Using this formula, and starting from a Fahrenheit temperature 0, using a Matlab loop determine when the approximate equivalence Celsius temperature differs from the exact equivalent value by more than four degrees.
Note: the exact conversion formula:
Celsius=(Fahrenheit-32)5/9
2 commentaires
Steven Lord
le 2 Juil 2020
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.
Réponses (1)
Image Analyst
le 2 Juil 2020
You got the > sign wrong for the loop. Plus you never updated the temperature in the loop to "temp" - you used Fahrenheit, which is a constant. Plus you never updated appCelsius in the loop. Here's a few of them fixed. See if you can finish it now.
temp=1;
Fahrenheit=0;
appCelsius=(Fahrenheit-30)./2;
realCelsius=(Fahrenheit-32)*5./9;
loopCounter = 1
maxIterations = 500;
while((realCelsius-appCelsius) < 4) && temp < 500
temp=temp+1;
realCelsius = (temp-32)*5./9;
fprintf('Degrees F = %d, Real Celsius = %f, Estimated Celsius = %f\n', temp, realCelsius, appCelsius);
end
disp(realCelsius);
0 commentaires
Voir également
Catégories
En savoir plus sur Physical Units dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!