Not enough input arguments error. where am I going wrong here?

bbfun = @(x1,x2) (4-2.1.*x1.^2+x1.^4/3).*x1.^2 + x1.*x2 + (-4+4*x2.^2) .*x2.^2;
[x1,x2] = meshgrid(-2:1/500:2, -1.5:1/500:1.5);
pltvar = bbfun(x1,x2);
contour(x1,x2,pltvar,50)
hold on
X1 = -1:1/15:1;
X2 = -0.5:2/15:0.5;
X = [X1 X2];
fplot = bbfun(X1,X2);
plot(fplot,X,'ro')
Not enough input arguments.
Error in q2_b2>@(x1,x2)(4-2.1.*x1.^2+x1.^4/3).*x1.^2+x1.*x2+(-4+4*x2.^2).*x2.^2
Error in q2_b2 (line 9)
fplot = bbfun(X);
I just need to plot 30 sample points on the contour generated by the first section of the code.

Answers (1)

The fplot call is wrong, however using ‘bbfun’ with ‘X1’ and ‘X2’ is not going to work because those vectors are different sizes. I am not certain what you want to do with that, so I am not certain how to advise you. In any event, it is not possible to use fplot with ‘bbfun’ because fplot requires functions of one variable and ‘bbfun’ requires two.

2 Comments

I'm new to MATLAB. I used the 'fplot' as a variable, incorrectly. I will change that. I just want to plot 30 points on the contour plot which are generated by subsituting those 30 points in the 'bbfun' function.
I have no idea which 30 points you want to plot, or how you want them to appear.
Experiment with this:
bbfun = @(x1,x2) (4-2.1.*x1.^2+x1.^4/3).*x1.^2 + x1.*x2 + (-4+4*x2.^2) .*x2.^2;
[x1,x2] = meshgrid(-2:1/500:2, -1.5:1/500:1.5);
pltvar = bbfun(x1,x2);
figure
contour(x1,x2,pltvar,50)
hold on
X1 = -1:1/15:1;
X2 = -0.5:2/15:0.5;
x2v = -1.5:1/500:1.5;
pv30 = interp1((-2:1/500:2)', pltvar', X1);
plotcol = pv30(:,1); % Plot Column 1
plot3(X1(:), ones(size(X1(:))), plotcol, 'o')
hold off
.

Sign in to comment.

Categories

Products

Release

R2019a

Asked:

on 9 May 2020

Commented:

on 9 May 2020

Community Treasure Hunt

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

Start Hunting!