I am a single function script called ‘TemperatureConvert.m’ that inputs some temperature in Celsius and outputs the temperature in Celcius, Kelvin, and Fahrenheit.
이전 댓글 표시
Knowing °K = °C + 273, and °F = ((9/5)* °C) + 32.
I created the first script defining a function:
function [kelvin, farenheit] = temperatureconvert(celcius)
kelvin = celcius + 273;
farenheit = (9./5).*(celcius + 2);
end
I then made a second script to call the function where I was told to calculate the converted temperature of the degrees 0 to 100 with an interval of 5 degree celcius. As shown below.
choice = input('input value for x')
for choice = 1:5:100
temp = temperatures(choice);
disp(temp)
end
I am getting values, but I know they are not right because I need to be getting outputs of both kelvin and farenheit. What should I change in order to get both these values for this set of celcius inputs, and why? I am fairly new to MATLAB and fairly understand the general functions and uses, but I am having trouble peicing them all together.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Power and Energy Systems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!