How to plot a contour plot with the next data

조회 수: 5 (최근 30일)
Sebastian
Sebastian 2014년 3월 2일
댓글: Sebastian 2014년 3월 2일
Hello everyone! I have been trying to plot some data within an equation, but I have not been able to figure it out.
In my X-axis I should have a linspace(0.28,0.4,9)
In my Y-values I should have linspace(1200,1400,9)
My Z values are this equation:
Z=2077+79.5A-76.3B
Where A=[-1 1 -1 -1 1 -1 1 1 0]
& B=[1 -1 1 -1 1 -1 -1 1 0]
Can someone help me with this? From what I have read I know that it should use meshgrids and it should be very simple but I am not very familiarized with the topic. Thank you!

채택된 답변

Mischa Kim
Mischa Kim 2014년 3월 2일
Hello Sebastian, I assume A is the x-parameter, B is the y-parameter?
x = linspace(0.28,0.40,9);
y = linspace(1200,1400,9);
A = [-1 1 -1 -1 1 -1 1 1 0];
B = [1 -1 1 -1 1 -1 -1 1 0];
[X,Y] = meshgrid(A, B);
Z = 2077 + 79.5*X - 76.3*Y;
figure
contour(Z)
set(gca,'XTickLabel',num2str(x'))
set(gca,'YTickLabel',num2str(y'))
  댓글 수: 2
Sebastian
Sebastian 2014년 3월 2일
I tried the same before, but the problem is that I need to have some diagonals lines in the image instead of what we are getting. I will attach the image for better understanding. Thank you Mischa!
I should get this image where the x-axis is the linspace(0.28,0.4,9) & the y-axis is linspace(1200,1400,9).
Sebastian
Sebastian 2014년 3월 2일
I figured it out, Thank you very much Mischa!!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by