Functions: converting Fahrenheit to Celsius
이전 댓글 표시
The question is to write a function f_to_c that accepts a temperature in degrees Fahrenheit and returns the temperature in degrees Celsius. The equation is:
T(in °C) = 5/9[T(in °F) - 32.0]
this is my whole script file and I keep getting this error when I try to use the function
>> f_to_c(100)
Error: File: f_to_c.m Line: 25 Column: 20
Function with duplicate name "f_to_c" cannot be defined.
can anyone tell me what is going on?
function Celsius = f_to_c(Fahrenheit)
Celsius = (5/9)*(Fahrenheit-32);
end
댓글 수: 4
madhan ravi
2019년 3월 18일
which f_to_c -all % what shows up?
steven butera
2019년 3월 20일
steven butera
2019년 3월 20일
답변 (2개)
Walter Roberson
2019년 3월 18일
1 개 추천
When you define a function inside a script, the function cannot have the same name as the script .m file.
Ahmad Saleh Faraz
2021년 9월 26일
0 개 추천
lsius = f_to_c(Fahrenheit)
Celsius = (5/9)*(Fahrenheit-32);
카테고리
도움말 센터 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!