Cross product error in plotting spiral?

2 visualizaciones (últimos 30 días)
Alec Lothian
Alec Lothian el 29 de Nov. de 2018
Comentada: Alec Lothian el 29 de Nov. de 2018
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

Respuestas (1)

KSSV
KSSV el 29 de Nov. de 2018
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 comentario
Alec Lothian
Alec Lothian el 29 de Nov. de 2018
Can you explain why you used the gradient function and what the x' notation means

Iniciar sesión para comentar.

Categorías

Más información sobre Special Functions en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by