# Matlab issue

1. Sep 10, 2009

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 similiar to those in that book.

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

#### Attached Files:

• ###### help.doc
File size:
28 KB
Views:
65
2. Sep 10, 2009

Just one correction
K=1/E is not correct, it should be K=(1/E)*(pi/2)^2

3. Sep 10, 2009

### sokrates

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. Sep 13, 2009