clear all close all X = -10:10; Y = -10:10; Z = -10:10; [X,Y,Z] = meshgrid(X,Y,Z
ID: 3583225 • Letter: C
Question
clear all close all X = -10:10; Y = -10:10; Z = -10:10; [X,Y,Z] = meshgrid(X,Y,Z); Hx=zeros(21,21,21); Hy=zeros(21,21,21); Hz=zeros(21,21,21);I=1; epslon = 8.854*10^-12; %%H=zeros(3,numel(i)); for z1 = [-5:-1,1:5] R = sqrt(X.^2+Y.^2+(Z-z1).^2);
i = X./R; j = Y./R; k = (Z-z1)./R; H = (I./(4*pi*R.^2)); for iloop = 1:numel(i)
c=cross([0,0,z1],[i(iloop),j(iloop),k(iloop)]); %%H(:,iloop) = H.*c+H(:,iloop);
Hx(iloop) = Hx(iloop)+H(iloop).*c(1); %%Hxt(iloop)= Hxt(iloop) + Hx(iloop);
Hy(iloop) = Hy(iloop)+H(iloop).*c(2); %%Hyt(iloop) = Hyt(iloop) + Hy(iloop);
Hz(iloop) = Hz(iloop)+H(iloop).*c(3); %%Hzt(iloop) = Hzt(iloop) + Hz(iloop);
end end %%fprintf('voltage between the two points:') %%rad=sqrt(2); %%V=(1/(4*pi*epslon))*(q/rad) quiver3(X,Y,Z,Hx,Hy,Hz) axis square hold on I took this code from. Friend and i need help with changing it but getting the same result clear all close all X = -10:10; Y = -10:10; Z = -10:10; [X,Y,Z] = meshgrid(X,Y,Z); Hx=zeros(21,21,21); Hy=zeros(21,21,21); Hz=zeros(21,21,21);
I=1; epslon = 8.854*10^-12; %%H=zeros(3,numel(i)); for z1 = [-5:-1,1:5] R = sqrt(X.^2+Y.^2+(Z-z1).^2);
i = X./R; j = Y./R; k = (Z-z1)./R; H = (I./(4*pi*R.^2)); for iloop = 1:numel(i)
c=cross([0,0,z1],[i(iloop),j(iloop),k(iloop)]); %%H(:,iloop) = H.*c+H(:,iloop);
Hx(iloop) = Hx(iloop)+H(iloop).*c(1); %%Hxt(iloop)= Hxt(iloop) + Hx(iloop);
Hy(iloop) = Hy(iloop)+H(iloop).*c(2); %%Hyt(iloop) = Hyt(iloop) + Hy(iloop);
Hz(iloop) = Hz(iloop)+H(iloop).*c(3); %%Hzt(iloop) = Hzt(iloop) + Hz(iloop);
end end %%fprintf('voltage between the two points:') %%rad=sqrt(2); %%V=(1/(4*pi*epslon))*(q/rad) quiver3(X,Y,Z,Hx,Hy,Hz) axis square hold on I took this code from. Friend and i need help with changing it but getting the same result clear all close all X = -10:10; Y = -10:10; Z = -10:10; [X,Y,Z] = meshgrid(X,Y,Z); Hx=zeros(21,21,21); Hy=zeros(21,21,21); Hz=zeros(21,21,21);
I=1; epslon = 8.854*10^-12; %%H=zeros(3,numel(i)); for z1 = [-5:-1,1:5] R = sqrt(X.^2+Y.^2+(Z-z1).^2);
i = X./R; j = Y./R; k = (Z-z1)./R; H = (I./(4*pi*R.^2)); for iloop = 1:numel(i)
c=cross([0,0,z1],[i(iloop),j(iloop),k(iloop)]); %%H(:,iloop) = H.*c+H(:,iloop);
Hx(iloop) = Hx(iloop)+H(iloop).*c(1); %%Hxt(iloop)= Hxt(iloop) + Hx(iloop);
Hy(iloop) = Hy(iloop)+H(iloop).*c(2); %%Hyt(iloop) = Hyt(iloop) + Hy(iloop);
Hz(iloop) = Hz(iloop)+H(iloop).*c(3); %%Hzt(iloop) = Hzt(iloop) + Hz(iloop);
end end %%fprintf('voltage between the two points:') %%rad=sqrt(2); %%V=(1/(4*pi*epslon))*(q/rad) quiver3(X,Y,Z,Hx,Hy,Hz) axis square hold on I took this code from. Friend and i need help with changing it but getting the same result
Explanation / Answer
clear all
close all
Z = -10:10;
X = -10:10;
Y = -10:10;
[Z,X,Y ] = meshgrid(Z,X,Y);
Hz=zeros(21,21,21);
Hx=zeros(21,21,21);
Hy=zeros(21,21,21);
I=1;
epslon = 8.854*10^-12;
%%H=zeros(3,numel(i));
for z1 = [-5:-1,1:5]
R = sqrt((Z-z1).^2+ X.^2+Y.^2);
k = (Z-z1)./R;
i = X./R;
j = Y./R;
H = (I./(4*pi*R.^2));
for iloop = 1:numel(i)
c=cross([0,0,z1],[i(iloop),j(iloop),k(iloop)]);
%%H(:,iloop) = H.*c+H(:,iloop);
Hz(iloop) = Hz(iloop)+H(iloop).*c(3);
%%Hzt(iloop) = Hzt(iloop) + Hz(iloop);
Hx(iloop) = Hx(iloop)+H(iloop).*c(1);
%%Hxt(iloop)= Hxt(iloop) + Hx(iloop);
Hy(iloop) = Hy(iloop)+H(iloop).*c(2);
%%Hyt(iloop) = Hyt(iloop) + Hy(iloop);
end
end
%%fprintf('voltage between the two points:')
%%rad=sqrt(2);
%%V=(1/(4*pi*epslon))*(q/rad)
quiver3(Z,X,Y,Hx,Hy,Hz)
axis square
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.