How to calculate Electric field analytically on Matlab?
이전 댓글 표시
Greetings!
I need to analytically calculate an Electric field.Here's the equation:

With my very basic knowledge of the software, here's the code:
if true
%function [E]= Etemp(x,y,z,x0,y0,z0,E0,t,c)
if z<z0,
E=E0;
else
E=-(1./(2*pi))*dblquad('E2(x0,yo)',inf,inf,inf,inf);
E2=(Rgv/(Rg^2))*((1/c)*z./norm(z)*diftE+((1/Rg)*z./norm(z)*E0));
clear,
syms ro Rg c t;
f=E0;
diftE=diff(f,t);
end
end
Beside the feeling of missing something with the code, I have encountered so far a problem with calculating the double indefinite integrals using "dblquad" because it doesn't seems right. Same with using "diff" with indefinte differentials.
I have no experience in this domain and I'm definitely afraid that I'm missing something here (too good to be true. This has to be more complicated then that ). So I'll be eternally grateful for any help.
Thanks very much for any kind of help!
댓글 수: 7
tlawren
2012년 6월 29일
Do you have E(r0,t) in analytic form? If not, then I don't see how you can go much further then what you've already got. Where does your original equation come from? Are you sure that you don't need to solve the equation numerically?
Sebsatien
2012년 6월 29일
편집: Walter Roberson
2012년 6월 29일
tlawren
2012년 6월 29일
What are you ultimately wanting to calculate? E(r,t) in the half-space opposite your field source? Are you wanting E(r,t) in analytical form or numerical? When you use quadrature (dblquad) and finite difference methods (diff), then you are doing numerical calculations. If E0 comes from a scanning plane, then I envision E0 as a mesh of data points in time. Maybe even a 3D matrix, where two dimensions are spatial and the third is time. With such data, you should then be able to calculate E(r,t) in on a discrete space. r0 is your spatial probing point, right? It's been awhile since I've studied Classical EM, so my knowledge is a little rusty.
tlawren
2012년 6월 29일
Now that I think about it, are you wanting to solve for E (and B/H) in the half-space opposite your source given knowledge of E on the plane dividing your space?
Do you have an example of E0? It's format will determine how you calculate d/dt[E0]. It might be a good idea to work out the cross products in the integrand, so that you can evaluate each of the field components separately. In the snippet of code you posted, you use the standard multiplication operator (*). Matlab has a cross product function (cross), but you need to look at it's documentation before you use it. I'm not familiar with dblquad, so I can't really say much about it. I can say that using inf for your limits of integration is probably not a good idea. There are probably practical limits you can use, but they will be problem specific. In fact, you might have to run some simulations to determine what good limits will be.
채택된 답변
추가 답변 (2개)
Antonio Cedillo Hernandez
2020년 4월 21일
1 개 추천
Here you have the full MATLAB code explained (in spanish but the first comment is the code): https://www.youtube.com/watch?v=k9srU6aQfL0
카테고리
도움말 센터 및 File Exchange에서 Nearest Neighbors에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!