Having trouble using a function
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
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 Kommentar
John Harris
am 26 Mär. 2018
In the first line, your function doesn't require any inputs. Try changing your first line to:
T = Function_T(h,Ve)
Antworten (2)
Birdman
am 26 Mär. 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
am 26 Mär. 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
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!