mesh from 1D (creating a matrix from a vector)

Hello,
I have a vector A[-3:0.003:3] and a vector B whose values corresponding to those of A. I plotted B as a function of A ( it shows a curve like a gaussian). I would like now to plot in 3D using mesh. From vector A, i have to use two vectors x and y and I have to find a matrix from vector B.
Any help and I thank you in advance!
Adam

답변 (1개)

Matt J
Matt J 2012년 11월 1일

0 개 추천

Sounds like MESHGRID or NDGRID is what you want.

댓글 수: 4

adam
adam 2012년 11월 1일
편집: adam 2012년 11월 1일
Thank you! yes to create x and y , we can use ndgrid [x y]=ndgrid([A]) But I don't know why do I create a matrix from the vector B, whose the values corresponding to the vectors x and y
I hope that my question is clear
Thank you
Well, that depends on the functional form of B. The general benefit of ndgrid/meshgrid, however, is that you can now do element-wise operations involving x and y to generate B:
B=x.^2+y.^2;
mesh(x,y,B);
adam
adam 2012년 11월 2일
Hello, Thank you for your answer. But you didn't understand my question.
- I create two vectors x and y from the vector A provided that A=x.^2+y.^2.
- I have to create a matrix C from the vector B.
In this case i can plot mesh(x,y,C)
Thank you!
Matt J
Matt J 2012년 11월 2일
Hello, Thank you for your answer. But you didn't understand my question.
Still don't...

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

카테고리

도움말 센터File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

질문:

2012년 11월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by