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 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Cris LaPierre
on 7 Dec 2018
5 Comments
Cris LaPierre
on 8 Dec 2018
Edited: Cris LaPierre
on 8 Dec 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')

See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!