Integrating a line integral e^x(sinydx + cosydy) over an ellipse 4(x+1)^2 + 9(y-3)^2 = 36

조회 수: 6 (최근 30일)
I also would like to disp the function over the region as a plot or vector field

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2023년 1월 24일
편집: Bjorn Gustavsson 2023년 1월 24일
For the integration you should use Green's theorem. It is beautiful, especially for this case.
For the vector-field-plot you can use quiver, see the help and documentation for that function. There are also a couple of color-enhanced variations available on the file exchange: quiver-magnitude-dependent-color-in-2d-and-3d, cquiver, ncquiverref and quiverc (it is rather likely that I've missed some variant, but you can search on further). You could do something like:
phi360 = linspace(0,2*pi,361);
x0 = -1;
y0 = 3;
xE = x0 + sqrt(36/4)*cos(phi360);
yE = y0 + sqrt(36/9)*sin(phi360);
plot(xE,yE,'k','linewidth',2)
[x,y] = meshgrid(-4.5:0.1:2.5,0.5:0.1:5.5);
fx = @(x,y) exp(x).*sin(y);
fy = @(x,y) exp(x).*cos(y);
quiver(x,y,fx(x,y),fy(x,y)) % Either of these 4 calls to quiver, or with some
quiver(x,y,fx(x,y),fy(x,y),1) % normalization of your own, I like the color-
quiver(x,y,fx(x,y),fy(x,y),0) % capable extensions, because then one can
quiver(x(1:5:end,1:5:end),... % plot the unit-vectors of the direction of
y(1:5:end,1:5:end),... % the forces and have their magnitude in color
fx(x(1:5:end,1:5:end),y(1:5:end,1:5:end)),...
fy(x(1:5:end,1:5:end),y(1:5:end,1:5:end)),0)
for i1 = 1:10:numel(phi360)
xC = xE(i1);
yC = yE(i1)
FxC = fx(xC,yC);
FyC = fy(xC,yC);
arrow3([xC,yC],[xC,yC]+[FxC,FyC]) % or arrow, both available on the FEX
end
You now have a solution to your task. If you look up the Green's theorem link on Wikipedia you should also make an additional pseudocolor-plot, likely put that one first in the script. You should also comment and work out exactly what happens on each line. (the normalization of quiver is a bit fiddly to get a nice and ballanced figure)
HTH
  댓글 수: 2
Yuva
Yuva 2023년 1월 24일
i added a hold on before the for to still have the previous plot
Bjorn Gustavsson
Bjorn Gustavsson 2023년 1월 24일
@Yuva, good that it helped. The answer was a bit quick. When it comes to graphics it is possible to further decorate and combine different presentations to make better figures.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Vector Fields에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by