2 views (last 30 days)
menna sharaf on 2 Jul 2020
Edited: .. on 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

Steven Lord on 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.
.. on 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);

Image Analyst on 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);