
'Matrix dimensions must agree error'
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aditya Jadhav
am 7 Mai 2020
Kommentiert: Aditya Jadhav
am 7 Mai 2020
bbfun = @(x1,x2) (4-2.1.*x1.^2+x1.^4/3).*x1.^2 + x1.*x2 + (-4+4*x2.^2) .*x2.^2;
x1 = -2:1/100:2;
x2 = -1.5:1/100:1.5;
pltvar = bbfun(x1,x2);
contour(x1,x2,pltvar,20)
Error:
Matrix dimensions must agree.
Error in q2_a>@(x1,x2)(4-2.1*x1.^2+x1.^4/3).*x1.^2+x1.*x2+(-4+4*x2.^2).*x2.^2
Error in q2_a (line 5)
pltvar = bbfun(x1,x2);
Why am I getting this error? What am I doing wrong?
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 7 Mai 2020
Bearbeitet: Ameer Hamza
am 7 Mai 2020
You need a mesh to create contour plot
bbfun = @(x1,x2) (4-2.1.*x1.^2+x1.^4/3).*x1.^2 + x1.*x2 + (-4+4*x2.^2) .*x2.^2;
x1 = -2:1/100:2;
x2 = -1.5:1/100:1.5;
[X1, X2] = meshgrid(x1, x2);
pltvar = bbfun(X1, X2);
contour(X1, X2, pltvar,20)

Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!