Having trouble using a function

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 Comment

In the first line, your function doesn't require any inputs. Try changing your first line to:
T = Function_T(h,Ve)

Answers (2)

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);
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

This question is closed.

Asked:

on 26 Mar 2018

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!