I have two fucntions with identical independent variable x. I need to draw a 2D contour plot for that two fucntions. But my code is not runnig. Pl somebody help me.
syms x
y1=x^.3+x+1;
y2=4.*x.^2;
x=linspace(0,5,30)
[X]=meshgrid(x);
F1=y1(X);
F2=y2(X);
contourf(F1(X), F2(X))
This code is not runnig. I need to get a filled contour with F1 and F2.

 채택된 답변

Walter Roberson
Walter Roberson 2020년 5월 13일

0 개 추천

Guessing about what you might maybe mean:
syms x
y1(x)=x^.3+x+1;
y2(x)=4.*x.^2;
x=linspace(0,5,30);
[X]=meshgrid(x);
F1=y1(X);
F2=y2(X);
subplot(1,2,1)
contourf(x, x, F1);
title('y1')
axis equal
subplot(1,2,2)
contourf(x, x, F2);
title('y2')
axis equal

댓글 수: 5

AVM
AVM 2020년 5월 13일
@walter: Thanks for your reply. But I need to draw the 2D contour by allowing y1 as the vertical axis( y axis) and y2 along horizontal axis(x axis).
Walter Roberson
Walter Roberson 2020년 5월 13일
If you do that... then what is the z value? Contours require different values of z
AVM
AVM 2020년 5월 13일
can I consieder X as Z in that case?
AVM
AVM 2020년 5월 13일
편집: AVM 2020년 5월 13일
Actually I need to see as x changes, then what is corresponding chages of y2 as y1 will be changing. I need to know the behaviour of y2 as y1 changes from a 2D contour plot.
Actually I need to see as x changes, then what is corresponding chages of y2 as y1 will be changing.
All I can think of that you might mean for that would be like
dy1 = diff(y1);
dy2 = diff(y2);
fplot(dy2-dy1, [0 5])
Your y1 and y2 are each single dimensional; there is no reason to be using meshes and contour plots with them.

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

추가 답변 (0개)

카테고리

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

태그

질문:

AVM
2020년 5월 13일

댓글:

2020년 5월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by