I am trying to create a surface plot with nested loops and am getting the error "Z must be a matrix, not a scalar or vector."

1 vue (au cours des 30 derniers jours)
clear all
n=1;
for ii = 1:10;
for jj = 1:10;
x(n) = ii;
y(n) = jj;
z(n) = ii+jj;
n = n+1;
end
end
surf(x,y,z)

Réponse acceptée

G A
G A le 22 Avr 2019
Modifié(e) : G A le 24 Avr 2019
Try something like the following (z must be a matrix):
for m = 1:10
x(m) = m;
for n = 1:10
y(n) = n;
z(m,n) = n+m;
end
end
surf(x,y,z)

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by