Please help to solve this

3 Ansichten (letzte 30 Tage)
menna sharaf
menna sharaf am 2 Jul. 2020
Bearbeitet: .. am 2 Jul. 2020
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 Kommentare
Steven Lord
Steven Lord am 2 Jul. 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.
..
.. am 2 Jul. 2020
Bearbeitet: .. am 2 Jul. 2020
i tried to write it but somthing not right
Fahrenheit=0;
appCelsius=fix(Fahrenheit-30)./2;
while((realCelsius-appCelsius)>4)
Fahrenheit=Fahrenheit+1;
realCelsius=fix(Fahrenheit-32)*5./9;
end
disp(Fahrenheit);

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 2 Jul. 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);

Kategorien

Mehr zu Physical Units finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by