I want to plot a contour graph to display Z with respect to X and Y. If Z = a*X + b*Y, I can plot a contour. However, If Z is a matrix that gained from training Neural Network or measured values how I can plot on a contour graph? Can you help me?
Happy New Year.

 채택된 답변

Star Strider
Star Strider 2016년 1월 1일

0 개 추천

You can plot any matrix using the contour function.
For example:
Z = rand(10,12);
figure(1)
contour(Z)
grid
You do not necessarily have to define ‘X’ and ‘Y’, although it gives you more control over the appearance of the plot that contour produces than without them.
We do not have your data, and I do not understand the reason you have apparently not been able to get a good plot from contour with your matrix. If you can upload your data as a .mat file (use the save function, and then click the ‘paperclip’ icon, and complete both the ‘Choose file’ and ‘Attach file’ steps to upload the file) we can help you solve the specific problem you are experiencing.

댓글 수: 4

Tien Tran
Tien Tran 2016년 1월 2일
편집: Tien Tran 2016년 1월 2일
Thank for your answer.
I have tried to follow your method, however I don't control the scale of x-axis and y-axis. My data is attached in following file and a image that I want to gain. Can you help me resolve this problem? [X=Tpr=Data(: ,1); Y=Ppr(: ,2), Z=(: ,3) ]. Happy New Year.
The x and y axis scales appear to be appropriate when I plot them, simply reversed. The easiest way to get them to correspond to the axes in the image is to simply transpose ‘Data’ in the contour call:
contour(Data.')
This results in the correct value ranges for the axes so that they correspond to those in the image you posted.
Tien Tran
Tien Tran 2016년 1월 2일
my result like the attached file. The scale of y-axis is too large (y = (0, 30) ) and z have a scale of colorbar to be diffirent. How can I correct it like above sample?
The y-axis looks correct to me, and in the data you attache, goes from 1 to 3, not 30. If you want to restrict it to for instance 1.18 to 3, use an axis function call after your contour call:
axis([xlim 1.18 3])
There are several ways to deal with the colorbar scale, the easiest being to simply scale the Z values (in your code, ‘Data’) to be the same as those in the data you want to reproduce, for instance multiplying it by 0.055/25.
I mention parenthetically that the correct approach to the colorbar scaling is to change your code to produce the appropriate results, not scaling the result to match the data you want to reproduce. I’m not certain what you’re doing or how you’re doing it, assuming I have the background to understand it anyway. That is simply the approach I would take, were it my problem to solve.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

질문:

2015년 12월 31일

댓글:

2016년 1월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by