3D-plot of circular elements inside a matrix

조회 수: 2 (최근 30일)
Mehdi
Mehdi 2012년 5월 5일
Hi all,
I want to use meshc command and draw some elements inside a matrix that the elements indexes make a circle. for example in matrix A , I want to draw just the elements greater than 0:
A=[ 0 0 2 0 0;
0 1 3 2 0
3 4 2 1 3
0 2 3 5 0
0 0 4 0 0];
I want to eliminate the elements that are zero and draw the other elements in 3D. by doing so, we can clearly see the X-Y plane contours in 3-D plot.
Any reply is really appreciated.
Thanks
  댓글 수: 3
Sean de Wolski
Sean de Wolski 2012년 5월 7일
What do you expect as a result? Okay, we do _something_ to the zero elements, I'm not clear on what. Then we do _something_ and magically have a 3-d shape/plot. This is not clear to me. Please explain the two somethings and the expected result.
Mehdi
Mehdi 2012년 5월 7일
as you can see there are some zero elements at the corners of matrix A. I want to plot matrix A using 'meshc', without plotting zeros. just positive elements.

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

채택된 답변

Sean de Wolski
Sean de Wolski 2012년 5월 7일
A=[ 0 0 2 0 0;
0 1 3 2 0
3 4 2 1 3
0 2 3 5 0
0 0 4 0 0];
A(~A) = nan; %nan out the zeros
meshc(A)
  댓글 수: 1
Mehdi
Mehdi 2012년 5월 7일
Thanks a lot.
This is what I was looking for, exactly. :)

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

추가 답변 (1개)

Mehdi
Mehdi 2012년 5월 7일
Another thing,
Suppose that obtained a matrix like A, using Monte Carlo simulation by running a program so many times. But the final result of A is jagged when we plot it using 'meshc'.
How can we make it smooth?
  댓글 수: 3
Mehdi
Mehdi 2012년 5월 7일
Thanks for your help. as you know conv2() is a two dimensional convolution. but how to find the other matrix to convolve with A?! I think it is so important. how should we find B in a way that the shape of A doesn't change after convolution?!!
Mehdi
Mehdi 2012년 5월 7일
I used 'smooth' command and the result was so good.
Thank you anyway

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by