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 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Cris LaPierre
2018년 12월 7일
댓글 수: 5
Cris LaPierre
2018년 12월 8일
편집: Cris LaPierre
2018년 12월 8일
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')

참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!