필터 지우기
필터 지우기

surfC with 4 vectors

조회 수: 1 (최근 30일)
Kevin
Kevin 2011년 9월 28일
Hello, Quick question : is it possible to make surfc works with vectors ? I have 4 vectors (x,y,z & c for the color) of the same length (1 point per quadruple xyzc ) but I don't understand how to turn them into matrix as surfc asks me. The xyz points are uniformly spaced. Any idea ?

채택된 답변

Grzegorz Knor
Grzegorz Knor 2011년 9월 28일
Use reshape function, or interpolate the data:
  댓글 수: 5
Grzegorz Knor
Grzegorz Knor 2011년 9월 28일
Matrices can be any size, but you need to know it.
[x,y] = meshgrid(-2:.1:2, -2:.2:2);
x = x(:);
y = y(:);
z = x.*exp(-x.^2 - y.^2);
c = abs(z);
surfc(reshape(x,21,41),reshape(y,21,41),reshape(z,21,41),reshape(c,21,41))
Kevin
Kevin 2011년 9월 28일
It works thanks but I had to add a value because the lenght of my data was a prime number...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by