I am having problems creating user defined function. Here is the code I used. When I run it, I am keep getting error in line two and Not enough input arguements

2 views (last 30 days)
  3 Comments
Shivanesh Sivakumar
Shivanesh Sivakumar on 8 Dec 2021
V = 1/4*π^2 (j + k)(k − j)^2 , and A = π^2*(𝑘^2 − 𝑗^2 )
i was asked to create a user defined function that computes the above V and A with arguement j and k
Rik
Rik on 8 Dec 2021
What value did you assign to k outside of your function? Remember that your function doesn't know anything about the variable names outside of in, and your calling code doesn't know anything about the variable names inside the function.

Sign in to comment.

Answers (1)

Dyuman Joshi
Dyuman Joshi on 8 Dec 2021
Call like this -
[x,y] = torus(1,2) %single input/output
[x,y] = torus([1 2 3], [2 3 4]) %array input/output
or initialize j and k before calling the function
j=1;k=2;
[x,y] = torus(j,k) %single input/output
j=[1 2 3];k=[2 3 4];
[x,y] = torus(j,k) %array input/output

Categories

Find more on Entering Commands in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!