필터 지우기
필터 지우기

How to calculate Electric field analytically on Matlab?

조회 수: 18 (최근 30일)
Sebsatien
Sebsatien 2012년 6월 29일
답변: Antonio Cedillo Hernandez 2020년 4월 21일
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
tlawren 2012년 6월 30일
편집: tlawren 2012년 6월 30일
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.
Sebsatien
Sebsatien 2012년 7월 1일
편집: Sebsatien 2012년 7월 1일
The calcuation of E0 is the next level of the work, I'll need another set of equations for calculating fields in a certain point and I'll be looking into it very soon... Thanks of the "cross" tip, I'll need to study its case further. As for dblquad I'm looking into a symbolic way for evaluating integrals, which is more approriate then this operator. Thanks for the help. I'll see what I can do for now

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

채택된 답변

Walter Roberson
Walter Roberson 2012년 6월 29일
Going through what you have written, it appears that your E0 is a numeric matrix. If that is the case, then you cannot do a symbolic differentiation on it. Your f=E0 would be numeric, and diff(f,t) would try to apply the numeric diff() routine (numeric difference between adjacent points) which would promptly complain because the numeric diff() routine cannot accept a symbolic argument for the number of the dimension to operate on.
If E0 is indeed numeric, then diff(sym(f),t) would try to apply the symbolic diff() routine (symbolic differentiation), but since none of the symbolic values would involve the reference variable "t", the differentiation result would be a matrix of symbolic zeros.
  댓글 수: 3
tlawren
tlawren 2012년 6월 30일
편집: tlawren 2012년 6월 30일
Is the use of infinite limits still a good idea? I'm not familiar with these routines or their underlying algorithms, so I don't know. I've always sought out finite limits (practical infinities) to use instead.
Sebsatien
Sebsatien 2012년 7월 1일
Thanks. I suspected as much. I'll look into quadgk and I'll see how to replace the diff with a more convienent operator.

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

추가 답변 (2개)

Antonio Cedillo Hernandez
Antonio Cedillo Hernandez 2020년 4월 21일
Here you have the full MATLAB code explained (in spanish but the first comment is the code): https://www.youtube.com/watch?v=k9srU6aQfL0

Sebsatien
Sebsatien 2012년 7월 4일
Now I'm concentrating in the calculation of the EO, so I searched for equations to calculate the electric field in a point emitted by an electric elementary dipole. Here's the forumla:
So, would I be able to calculate the field using this equation on MATLAB? Is it programmable without eventual problems?
Thanks so much!

카테고리

Help CenterFile Exchange에서 Signal Generation and Preprocessing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by