5D array and Out of memory error
Afficher commentaires plus anciens
clc
clear all
theta0=pi/2;
a_0=6e-2;
r0=a_0;
r_d=a_0;
N_R=20;
drho=(r_d)/N_R;
Mphi=30;
dphi2=2*pi/Mphi;
Mtheta=30;
dtheta=pi/Mtheta;
M_phi=120;
dphi0=2*pi/M_phi;
r2=0:drho:r_d;
phi2=0:dphi2:2*pi;
theta2=0:dtheta:pi;
phi0=0:dphi0:2*pi;
xd=zeros(length(r2),length(theta2),length(phi2));
yd=zeros(length(r2),length(theta2),length(phi2));
zd=zeros(length(r2),length(theta2));
x0=r0*sin(theta0)*cos(phi0);
y0=r0*sin(theta0)*sin(phi0);
z0=r0*cos(theta0);
dx=zeros(length(r2),length(theta2),length(phi2),length(phi0));
dy=zeros(length(r2),length(theta2),length(phi2),length(phi0));
dis=zeros(length(r2),length(theta2),length(phi2),length(phi0));
for nr=1:length(r2)
for nt=1:length(theta2)
for mp=1:length(phi2)
xd(nr,nt,mp)=r2(nr)*sin(theta2(nt))*cos(phi2(mp));
yd(nr,nt,mp)=r2(nr)*sin(theta2(nt))*sin(phi2(mp));
zd(nr,nt)=r2(nr)*cos(theta2(nt));
end
end
end
dz=z0-zd;
for mg=1:length(phi0)
dx(:,:,:,mg)=x0(mg)-xd(:,:,:);
dy(:,:,:,mg)=y0(mg)-yd(:,:,:);
end
for nr=1:length(r2)
for nt=1:length(theta2)
for mp=1:length(phi2)
for mg=1:length(phi2)
dis(nr,nt,mp,mg)=sqrt(dx(nr,nt,mp,mg)^2+dy(nr,nt,mp,mg)^2+dz(nr,nt)^2);
end
end
end
nr
end
eps0=(10^-9)/(36*pi);
mu0=4*pi*10^-7;
epsr1=1.;
epsr2=3.45;
mur1=1.;
mur2=1.;
eps1=epsr1*eps0;
sigma=3e-7;
mu1=mur1*mu0;
mu2=mur2*mu0;
freq=8e9:10e6:10e9;
omeg=zeros(1,length(freq));
eps2=zeros(1,length(freq));
kd=zeros(1,length(freq));
for nf=1:length(freq)
omeg(nf)=2*pi*freq(nf);
eps2(nf)=epsr2*eps0-1j*(sigma/omeg(nf));
kd(nf)=omeg(nf)*sqrt(eps2(nf)*mu2);
end
Gxx=zeros(length(r2),length(theta2),length(phi2),length(phi0),length(freq));
for nf=1:length(freq)
Gxx(:,:,:,:,nf)=((3*(((kd(nf)^2).*dis(:,:,:,:).^4).^(-1)))-(3.*1j.*(kd(nf).*(dis(:,:,:,:).^3)).^(-1))-...
(dis(:,:,:,:).^-2)).*(exp(1j*kd(nf).*dis(:,:,:,:)).*(4*pi*dis(:,:,:,:)).^(-1)).*...
(dx(:,:,:,:).^2)+(1.+((kd(nf).*dis(:,:,:,:)).^(-1))-(((kd(nf)^2).*(dis(:,:,:,:)).^2).^(-1))).*...
(exp(1j*kd(nf).*dis(:,:,:,:)).*(4*pi*dis(:,:,:,:)).^(-1));
nf
end
Hi, I need to calculate the Gxx (Dyadic Green's Function) but I got memory error. I don't know how to calculate it easier and I can't decrease the dimensions. I need help, if anyone can help me , I'll appreciate.
Here is my memory.
Maximum possible array: 1763 MB (1.849e+09 bytes) *
Memory available for all arrays: 1763 MB (1.849e+09 bytes) *
Memory used by MATLAB: 4660 MB (4.887e+09 bytes)
Physical Memory (RAM): 4094 MB (4.293e+09 bytes)
* Limited by System Memory (physical + swap file) available.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Code Performance dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!