How can I plot a figure with multiplying a vector with matrices?
Afficher commentaires plus anciens
How can I plot the below figure in matlab?

I tried the below source code:
[X,Y] = meshgrid(-6:0.1:6);
Z = [X Y].*[2 1;1 3].*([X Y].') + [1 2].*[X Y].' + 3;
surf(X,Y,Z)
colormap(jet)
colorbar
and
[X,Y] = meshgrid(-6:0.1:6);
Z = [X Y]*[2 1;1 3]*([X Y].') + [1 2]*[X Y].' + 3;
surf(X,Y,Z)
colormap(jet)
colorbar
However, it showed the errors:
Error using .*
Matrix dimensions must agree.
Error in Fig20_3 (line 2)
Z = [X Y].*[2 1;1 3].*([X Y].') + [1 2].*[X Y].' + 3;
and
Error using *
Inner matrix dimensions must agree.
Error in Fig20_3 (line 2)
Z = [X Y]*[2 1;1 3]*([X Y].') + [1 2]*[X Y].' + 3;
Réponses (2)
Walter Roberson
le 29 Juil 2020
1 vote
This is a case where you need the * operator instead of the .* operator
4 commentaires
Walter Roberson
le 29 Juil 2020
you will also need some reshape operations. I will post a bit later.
TRUNG HOANG
le 29 Juil 2020
Modifié(e) : TRUNG HOANG
le 29 Juil 2020
Walter Roberson
le 30 Juil 2020
I think it might be easiest to expand the expression:
[X,Y] = meshgrid(-6:0.1:6);
Z = X + 2*Y + X .* (2*X + Y) + Y .* (X + 3*Y) + 3;
surf(X, Y, Z, 'edgecolor', 'none')
madhan ravi
le 30 Juil 2020
TRUNG HAONG comments:
Good.
madhan ravi
le 28 Juil 2020
doc fsurf
Catégories
En savoir plus sur Line Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!