Effacer les filtres
Effacer les filtres

Error using surf (line 71) Data dimensions must agree

2 vues (au cours des 30 derniers jours)
Hélène Parisot-Dupuis
Hélène Parisot-Dupuis le 28 Nov 2023
Commenté : Walter Roberson le 28 Nov 2023
Hello,
I have the kind of problem with my code and I don't understand why:
for it=1:2
xt(it,1)=it
for jt=1:3
yt(1,jt)=jt
zt(it,jt)=it+(jt-1)
end
end
figure;
surf(xt,yt,zt,'EdgeColor', 'None', 'facecolor', 'interp');
view(2);
colormap(jet(256));
c = colorbar;
Could you help me to find my error please?
Thanks in advance!

Réponses (1)

Alan Stevens
Alan Stevens le 28 Nov 2023
More like this?
for it=1:2
for jt=1:3
zt(it,jt)=it+(jt-1);
end
end
[x,y] = meshgrid(1:3,1:2);
figure;
surf(x,y,zt,'EdgeColor', 'None', 'facecolor', 'interp');
view(2);
colormap(jet(256));
c = colorbar;
  4 commentaires
Hélène Parisot-Dupuis
Hélène Parisot-Dupuis le 28 Nov 2023
Thank you very much for this clarification!
Voss
Voss le 28 Nov 2023
You're welcome!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by