How do I make this script into a function?
Mostrar comentarios más antiguos
%This program is a Slope Calculator.
%This program will calculate the slope in degrees from percent slope
disp('Would you like to calculate the internal angle?')
x = input('Please input rise/run as the gradient: ');
deg = (180/pi)*atan(x/100);
disp(deg)
end
Respuestas (1)
Walter Roberson
el 30 de Nov. de 2016
Just before all of that, add the line
function SlopeCalculator
where the word SlopeCalculator must be the same as the base name of the .m file it is stored in.
2 comentarios
M Pasanen
el 30 de Nov. de 2016
Walter Roberson
el 30 de Nov. de 2016
No. It is not required that functions return values.
If you happen to want to return deg then you could use
function deg = SlopeCalculator
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!