Azzera filtri
Azzera filtri

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

5 visualizzazioni (ultimi 30 giorni)
I also would like to disp the function over the region as a plot or vector field

Risposta accettata

Bjorn Gustavsson
Bjorn Gustavsson il 24 Gen 2023
Modificato: Bjorn Gustavsson il 24 Gen 2023
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 Commenti
Bjorn Gustavsson
Bjorn Gustavsson il 24 Gen 2023
@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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Vector Fields in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by