range in fplot as variables
조회 수: 5 (최근 30일)
이전 댓글 표시
clear
clf
clc
syms x y
f=x*y*(x+y);
ylim=[x^2 x];
ylow=ylim(1);
yup=ylim(2);
sol=solve(ylim(1)==ylim(2),x);
a=sol(1);
b=sol(2);
xlim=[a b];
integral=int(int(f,y,ylim(1),ylim(2)),x,xlim(1),xlim(2));
disp('The integral of f in the region enclosed is')
disp(integral)
fplot(ylow,[a b])
hold on
fplot(yup)
for p=xlim(1):0.01:xlim(2)
line([p p],subs(ylim,x,p),'Color','#abdbd4')
end
hold off
the job is pretty simple i want to show the regio of integration for a double integral in order dx dy
i have to generalize the above code for any function so that range in fplot should [a b]
although when i run the code it gives me this error
apparently if i give the range as [0 1]
it has no issues
but not all functions will have integrating region in a specific range say [0 5] (default)
why doesn't fplot takes [a b] as the range
댓글 수: 0
채택된 답변
VBBV
2021년 12월 7일
편집: VBBV
2021년 12월 7일
clear
clf
clc
syms x y
f=x*y*(x+y);
ylim=[x^2 x]
ylow=ylim(1);
yup=ylim(2);
sol=solve(ylim(1)==ylim(2),x)
a=sol(1);
b=sol(2);
xlim=[a b];
I=int(int(f,y,ylim(1),ylim(2)),x,xlim(1),xlim(2));
disp('The integral of f in the region enclosed is')
disp(I)
fplot(ylow,[0 5])
hold on
fplot(yup,[0 5]) % specify the same range
axis([0 5 0 5])
for p=xlim(1):0.01:xlim(2)
line([p p],[subs(ylim,x,p)],'Color','red')
end
hold off
figure
for p=xlim(1):0.01:xlim(2)
line([p p],[subs(ylim,x,p)],'Color','red')
end
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!