calculate divergence

조회 수: 10 (최근 30일)
Tuyen Tran
Tuyen Tran 2012년 4월 11일
Hi everyone, I want to calculate divergence of 2-d vector filed A=exp(-(r/alpha)^2).*r. With vector r=x.ux + y.uy (ux: unit vector of x coordinate and uy: unit vector of y coordinate in Cartesian), r=sqrt(x^2 + y^2). alpha is a constant.
This is my code:
v=[-2:0.1:2];
[x,y]=meshgrid(v);
z=x;
r=sqrt(x.^2 + y.^2);
a=r.*exp(-(r./2)^2);
div = divergence(r,a);
contour(v,v,div); hold on;
quiver(div); But I make mistake, I can't write correctly vector A. Can you show me how to correct it? Thanks a lot

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2012년 4월 11일
so?
a=r.*exp(-(r./2).^2);
  댓글 수: 1
Tuyen Tran
Tuyen Tran 2012년 4월 11일
Thanks for your answer, but do I write vector A in the right way, I don't know if I convert vector r from Cartesian to cyclinder coordinate right or not?

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by