How do I plot a 3D surface where I have arrays x and y of same length and z values for each x and y value.
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
So my code looks like the following
for n = 1:640; %number of time steps
for q = 1:640; %number of axial increments on a tool
Find a certain force f(q) = ...; % find force for each q increment
K = 100
z(n,q) = f(q)/K;
end
end
Now at the end I want to generate a surface where there is a z value for every q and every n combination. So z is a (n x q) size matrix. So I want 640 time steps as x. 640 axial increments as y, and a z value for each x and y combination. So the z matrix has 640*640 size
0 commentaires
Réponses (1)
Cris LaPierre
le 7 Déc 2018
5 commentaires
Cris LaPierre
le 8 Déc 2018
Modifié(e) : Cris LaPierre
le 8 Déc 2018
The hypothetical code is creating variables with the correct size. What is the size of the variables created in your actual code? Put a breakpoint in at the surf command and see what the actual size of n, q and z are.
And to clarify, the documentation does not say that X, Y, and Z have to be matrices. X and Y can be matrices or vectors. Z in the only one that has to be a matrix. As a simple example, see below:
n=1:40;
q=1:60;
z = n'*q;
surf(n,q,z')

Voir également
Catégories
En savoir plus sur Graphics Performance 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!