I have three variables X,Y and Z, Z is calculated from row vectors of X and Y and then I want to plot a mesh of Z using X and Y as grid... I know how to meshgrid but I dont know how to extend Z vector corresponding to X and Y grid?

 채택된 답변

Star Strider
Star Strider 2015년 7월 9일

0 개 추천

Use meshgrid to create the ‘X’ and ‘Y’ meshes, then calculate ‘Z’ from them:
x = linspace(-3, 3, 50);
y = linspace(-1.5, 1.5, 30);
[X,Y] = meshgrid(x, y);
Z = sin(X) .* exp(Y);
figure(1)
mesh(X, Y, Z)
grid on
Note the use of element-wise multiplication (.*) in ‘Z’.

추가 답변 (0개)

카테고리

태그

질문:

2015년 7월 9일

답변:

2015년 7월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by