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

3 Comments

How are you executing this code? What are you pushing, in which area?
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
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)

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

Asked:

on 8 Dec 2021

Answered:

on 8 Dec 2021

Community Treasure Hunt

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

Start Hunting!