MATLAB Matlab Problem with Calculating Magnetic Field H

AI Thread Summary
The discussion revolves around a problem in MATLAB related to calculating the magnetic field H in the x-y plane due to a current loop. The original poster provided a Word document detailing the issue and the formulas involved, noting discrepancies between MATLAB results and manual calculations. They specifically mentioned an error in the formula for K, which was corrected by a participant. The corrected code produced a functional dependence similar to the expected results, although there were still concerns about the y-axis values being significantly larger than anticipated. Ultimately, the original poster resolved the issue, attributing the confusion to a mistake in their calculations. The conversation highlights the importance of precise formula implementation and parameter adjustments in MATLAB for accurate scientific computations.
jadelsky
Messages
13
Reaction score
0
Hey all. I have a little problem in Matlab. I attached word file in this post where the problem is explained because I can't write those formulas here.

It's not hard, just need to put few formulas together. I also wrote what i tried, but the result is not good. I calculated it manually and the result in Matlab isn't as expected.

I'm calculating magnetic field H in x-y plane due to current loop and I need to see how the field is changing according to radius of loop. I also wrote in word file what is expected, the result from one book, and results I calculated manually are very similar to those in that book.

If anyone can take few minutes, take a look and try to help me I wold be grateful. :)
 

Attachments

Physics news on Phys.org
Just one correction
K=1/E is not correct, it should be K=(1/E)*(pi/2)^2
 
The following code seems to work:

clear all;clc;
h=0;
a=1;
I=1;

r=0:1e-2:a;

k=sqrt((4*a*r)./((r+a).^2+h^2));
E=(sqrt(1-k.^2))*(pi/2);

K=(1./E)*(pi/2)^2;

H1=I/2*pi*sqrt((r+a).^2+h^2);

H2=K+(2*a*(r+a)./(((r+a).^2+h^2).*(1-k.^2))-(1./(1-k.^2))).*E;

H=H1.*H2

plot(r, H);
grid on;
xlabel('r(m)')
ylabel('H(A/m)');

--------

You made a mistake with the parenthesis of the sqrt for the lowercase 'k'
I corrected it and saw a functional dependence of something similar to what you have shown.

The y-axis values may not be right, but they depend on your parameters anyway...

Hope it helps...
 
Yes, thank you very much...it's something like thaht, but I don't get why the values for H are so much bigger than expected...for example in 0 I'm sure that H needs to be 0,5 and on this graf it is 10 times bigger...the funcion looks allright, but this results are confusing...
 
finally...it's ok...stupid mistake...now it is as it should be :)
 

Similar threads

Replies
2
Views
3K
Replies
4
Views
1K
Replies
5
Views
3K
Replies
4
Views
2K
Replies
4
Views
3K
Back
Top