mTuran
mTuran

Reputation: 1824

Pass Multiple Parameters To Function For Plot

I have function which takes 2 inputs:

function [r] = myfunc(x,y)

I want to plot this function but i get this error:

>> plot(myfunc, [1 2]);
Error using myfunc (line 2)
Not enough input arguments.

Upvotes: 0

Views: 230

Answers (2)

milad
milad

Reputation: 169

when you have 3 variables (i.e. x,y and r) you cannot use 2D plot and you should use plot3(x,y,myfunc(x,y)) instead.

Upvotes: 1

Justin Fletcher
Justin Fletcher

Reputation: 2409

If I understand your question, I think you're looking for this:

[r] = myfunc(x,y)
plot(x, y, r)

I'm assuming that myfunc takes x and y as vectors, and returns r as a vector. If not, let me know, and I'll post an edit explaining how to properly set up x, y, and z for use with plot.

Upvotes: 1

Related Questions