Cross product error in plotting spiral?

I have the following code
I = .017; %Amps
Hx = 0;
Hy = 0;
H = 0;
Px = 0;
Py = 0;
Pz = 1.65;
t = 0:3500;
u = .001857;
r0 = 10;
r = r0 +u*t;
omega = pi/250;
phi0 = 3*pi/2;
phi = -omega*t+phi0;
x = r .* cos(phi);
y = r .* sin(phi);
x = x - mean(x)
y = y - mean(y)
plot(x,y)
grid on;
dLx = diff(x);
dLy = diff(y);
dL = [dLx dLy 0];
aR = [Px-x Py-y Pz];
R = sqrt((Px-x).^2+(Py-y).^2+Pz.^2);
H = H + I*(cross(dL,aR))/(4*pi*R^2);
and I want to follow the following equation
EMF eq 2.PNG
but I get the follwoing error when run.
Error using cross (line 25)
A and B must be of length 3 in the dimension in which the cross product is taken.
Error in Project_2 (line 33)
H = H + I*(cross(dL,aR))/(4*pi*R^2);
Any ideas or help would be helpful

답변 (1개)

KSSV
KSSV 2018년 11월 29일

0 개 추천

I = .017; %Amps
Hx = 0;
Hy = 0;
H = 0;
Px = 0;
Py = 0;
Pz = 1.65;
t = 0:3500;
u = .001857;
r0 = 10;
r = r0 +u*t;
omega = pi/250;
phi0 = 3*pi/2;
phi = -omega*t+phi0;
x = r .* cos(phi);
y = r .* sin(phi);
x = x - mean(x);
y = y - mean(y);
plot(x,y)
grid on;
dLx = gradient(x');
dLy = gradient(y');
dL = [dLx dLy zeros(size(dLx))];
aR = [(Px-x)' (Py-y)' repmat(Pz,size(x))'];
R = sqrt((Px-x).^2+(Py-y).^2+Pz.^2)';
H = I*(cross(dL,aR))./(4*pi*R.^2);
H = cumsum(H) ; % you have to pick the last one

댓글 수: 1

Alec Lothian
Alec Lothian 2018년 11월 29일
Can you explain why you used the gradient function and what the x' notation means

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Graphics에 대해 자세히 알아보기

제품

릴리스

R2017b

질문:

2018년 11월 29일

댓글:

2018년 11월 29일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by