Matlab Problem with Calculating Magnetic Field H

In summary, the programmer tried to calculate the magnetic field due to a current loop, but the results were not as expected. He attached a word file with the problem and what he tried, along with expected results from one book and results he calculated manually.
  • #1
jadelsky
13
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

  • help.doc
    28 KB · Views: 192
Physics news on Phys.org
  • #2
Just one correction
K=1/E is not correct, it should be K=(1/E)*(pi/2)^2
 
  • #3
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...
 
  • #4
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...
 
  • #5
finally...it's ok...stupid mistake...now it is as it should be :)
 

Related to Matlab Problem with Calculating Magnetic Field H

What is MATLAB and how does it calculate magnetic fields?

MATLAB is a powerful software primarily used for numerical computing and data analysis. It can also be used for simulations, creating graphical user interfaces, and programming. Using MATLAB, one can solve complex mathematical problems, including calculating magnetic fields. The software uses various algorithms and equations to perform these calculations.

What are the inputs required to calculate a magnetic field using MATLAB?

The inputs required to calculate a magnetic field in MATLAB include the position and orientation of the magnetic field source, the location of the point where the magnetic field is to be calculated, and the strength and direction of the current or magnetization of the source.

Can MATLAB be used to calculate magnetic fields in different materials?

Yes, MATLAB has built-in functions and toolboxes that allow for calculations of magnetic fields in different materials, including ferromagnetic, paramagnetic, and diamagnetic materials. These materials have different magnetic properties that affect the strength and direction of the magnetic field.

How accurate are the magnetic field calculations in MATLAB?

The accuracy of the magnetic field calculations in MATLAB depends on the inputs provided and the chosen algorithm. If the inputs are precise and the algorithm is appropriate, the results can be highly accurate. However, it is always recommended to cross-check the results with other methods or experimental data for validation.

Can MATLAB be used for advanced magnetic field calculations, such as time-varying fields?

Yes, MATLAB has advanced features that allow for the calculation of time-varying magnetic fields. It has functions to handle changing inputs, such as time-dependent currents, and can also perform simulations to visualize the behavior of the magnetic field over time.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
4K
  • Electromagnetism
Replies
10
Views
444
  • Introductory Physics Homework Help
Replies
9
Views
561
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
Back
Top