How to get cross product?
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I have problem in follolowing code,can any one help me to get cross product of E and B
clear all;
clc;
close all;
dim=64;
[kx,ky]=meshgrid(-1:2/(dim-1):1);
circ=sqrt(kx.^2+ky.^2)<1;
kx=kx/2;
ky=ky/2;
alp=asin(1);
k0=1/sin(alp);
k=256;
kz=sqrt(k0^2-(kx.^2+ky.^2));
Gx=sqrt(k0./kz).*((k0*ky.^2+kz.*kx.^2)./(k0*(kx.^2+ky.^2)));
Gy=sqrt(k0./kz).*((kz-k0).*kx.*ky)./(k0*(kx.^2+ky.^2));
Gz=sqrt(k0./kz).*(kx./k0);
l1=100;
z=-l1:1:l1;
c = numel(z);
mz=200/64;
n = size(kx);
Ex = zeros([k k c]);
Ey = zeros([k k c]);
Ez = zeros([k k c]);
q1 = exp(1i*kz*mz);
for jj=1:c
q2 = q1.^z(jj).*circ;
Ex(:,:,jj)=fftshift(fft2(q2.*Gx,k,k));
Ey(:,:,jj)=fftshift(fft2(q2.*Gy,k,k));
Ez(:,:,jj)=fftshift(fft2(q2.*Gz,k,k));
end
M1=Ex(k/2,:,:);
N1=squeeze(M1).';
E1=N1(l1+1,:);
M2=Ey(k/2,:,:);
N2=squeeze(M2).';
E2=N2(l1+1,:);
M3=Ez(k/2,:,:);
N3=squeeze(M3).';
E3=N3(l1+1,:);
c=3*10^8;
E=[E1 E2 E3];
B=E/c;
S=crossprodut(E,B);
thanks in advance
1 commentaire
Jan
le 4 Oct 2012
Please explain, what your code does and what it does not solve. Formatting the code properly would be a good idea also. It has been explained hundrets of times in this forum already, so I'm convinced you will find the reuquired information by your own.
Réponses (1)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!