I am a single function script called ‘TemperatureConvert.m’ that inputs some temperature in Celsius and outputs the temperature in Celcius, Kelvin, and Fahrenheit.
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Power and Energy Systems en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!