Matlab Problem with Calculating Magnetic Field H

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 2K views
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 :)