Having trouble using a function
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
Hi everyone. I am trying to create a function that computes an output 'T' using two inputs, 'h,Ve'. However, whenever i try to run the code i am hit by the error 'Not enough input arguments'. The code is as follows:
function[T] = Function_T
%Calculating for trim
%h = length of horizontal semi axis of ellipse
%Ve= length of vertical semi axis of ellipse
T= (1/(atan*(h/Ve)))-2/pi;
end
I then try to use this code by defining input values for h and ve and then running the function:
h=0.8;
Ve=0.9;
T=Function_T;
But still i get the same error message. Anyone know what i'm doing wrong? Cheers in advance.
1 comentario
John Harris
el 26 de Mzo. de 2018
In the first line, your function doesn't require any inputs. Try changing your first line to:
T = Function_T(h,Ve)
Respuestas (2)
Birdman
el 26 de Mzo. de 2018
Give input arguments to function. The function has a local workspace therefore it will not recognize the global variables:
function[T] = Function_T(h,Ve)
%Calculating for trim %h = length of horizontal semi axis of ellipse %Ve= length of vertical semi axis of ellipse
T= (1/(atan*(h/Ve)))-2/pi;
end
and
h=0.8;
Ve=0.9;
T=Function_T(h,Ve);
Star Strider
el 26 de Mzo. de 2018
You need to define it with input arguments in order to use it with them. Unlike Anonymous Functions it will not pick up variables from your workspace. You also need to remove the ‘*’ from the atan call.
function [T] = Function_T(h,Ve)
%Calculating for trim
%h = length of horizontal semi axis of ellipse
%Ve= length of vertical semi axis of ellipse
T= (1/(atan(h/Ve)))-2/pi;
end
h = 0.8;
Ve = 0.9;
T = Function_T(h,Ve)
T =
739.5731e-003
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!