Cross product error in plotting spiral?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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

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
0 commentaires
Réponses (1)
KSSV
le 29 Nov 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
Voir également
Catégories
En savoir plus sur Special Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!