Matlab Problem with Calculating Magnetic Field H

Click For Summary

Discussion Overview

The discussion revolves around a problem related to calculating the magnetic field H in the x-y plane due to a current loop using Matlab. Participants explore the formulation of the problem, share code snippets, and address discrepancies between expected and calculated results.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant describes their issue with Matlab, noting that their calculated results for the magnetic field H do not match expected values derived from a book.
  • Another participant corrects a formula related to the variable K, suggesting that K should be defined as K=(1/E)*(pi/2)^2 instead of K=1/E.
  • A participant provides a code snippet that appears to work, mentioning a correction made to the calculation of the variable k and noting that the y-axis values may not be accurate but depend on the parameters used.
  • One participant expresses confusion regarding the larger-than-expected values for H at certain points, specifically stating that at r=0, H should be 0.5 but is calculated to be ten times larger.
  • A later reply indicates that the initial confusion was resolved by the original poster, who identified a mistake in their calculations.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the initial discrepancies in the calculated values for H, but the original poster ultimately resolves their issue independently.

Contextual Notes

The discussion includes potential limitations related to the parameters used in the calculations and the specific definitions of variables, which may affect the results. However, these limitations remain unresolved.

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 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K