i ma getting error for my code as " Requested 1202x221430 (4.0GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive.See array size limit or preference?

3 ビュー (過去 30 日間)
my code is as -
1 - function prototype-
function dE_omega_dz = odefun(z, E_omega,~,~)
dE_omega_dz=zeros(length(E_omega),1);
Dk=60000;
n_2=5*10^-20;
tau=-300*10^-15:1*10^-15:300*10^-15;
pi=3.1415926535;
c=3*10^8;
deff=2.064*10^-12;
l=800*10^-9;
L_NL=6.8372e-18;
LGVM=0.6*10^-3;
I0=30*10^13;
% you would have to split the fields back in two:
E1_omega = E_omega(1:end/2);
E2_omega = E_omega(end/2+1:end);
% go back to time space to calculate the nonlinear part:
E1_t = ifft(E1_omega);
E2_t = ifft(E2_omega);
N=max(size(E1_t));
t=101.95*10^-15; % initial pulse widthin second
dt=1e-15/t;
dw=1/N/dt*2*pi;
w=dw*(-N/2:N/2-1);
% and calculate the derivatives:
dE_omega_dz(1:length(E_omega)/2) = fft(1i*conj(E1_t).*E2_t.*exp(1i*Dk*z) ...
+ 1i*2*pi*n_2*I0*L_NL/l*(abs(E1_t.^2 + ...
2*abs(E2_t.^2)).*E1_t));
dE_omega_dz(length(E_omega)/2+1:length(E_omega)) = 1i*w.*L_NL/LGVM * E2_t + fft(1i*E1_t.*E1_t.*exp(-1i*Dk*z)....
+ 1i*4*pi*n_2*I0*L_NL/l*(2*abs(E1_t.^2 + ...
abs(E2_t.^2)).*E1_t));
end
CALLING FUNCTION
%first electric field envelop in fourier space
clc
clear all
close all
clf;
Pi=30*10^13; %input('Enter the value of input power in mW ')
t=101.95*10^-15; %input('Enter the value of input pulse width in seconds ')
tau=-300*10^-15:1*10^-15:300*10^-15; %input('Enter time period with upper(U), lower(L) and interval between upper and lower interval(I) in this format L:I:U')
c=3*10^8;
E0=sqrt(Pi); %for ii=0.1:0.1:(s/10) %1*10^-7:1*10^-7:s %different fiber lengths
E1_t=E0*exp(-(tau/t).^2); % generation of an gaussian input pulse
subplot(2,1,1);
plot(tau,abs(E1_t).^2); % graph of input pulse
title('Input Pulse'); xlabel('Time in ps'); ylabel('intensity');
grid on;
hold on;
%second electric field envelop in fourier space
Dk=60000;
n_2=5*10^-20;
deff=2.064*10^-12;
tau=-300*10^-15:1*10^-15:300*10^-15;
pi=3.1415926535;
c=3*10^8;
N=max(size(E1_t));
t=101.95*10^-15; % initial pulse widthin second
dt=1e-15/t;
dw=1/N/dt*2*pi;
w=dw*(-N/2:N/2-1);
z=30*10^-3;
E2_t=(((w.*deff).*E1_t.^2).*exp(-1i*Dk*z))./(2*n_2*c*Dk);
%E2_t=(((w.*deff)*(E1_t.^2)).*exp(-1i*z.*Dk))./(2*n_2*c*Dk);
subplot(2,1,2);
plot(tau,abs(E2_t).^2);
deff=2.064*10^-12;
l=800*10^-9; % lambda
% patching of the E1 and E2 electric fields with:
E1_omega=fft(fftshift(E1_t));
E2_omega=fft(fftshift(E2_t));;
E_omega=[E1_omega,E2_omega]
disp(E_omega)
zspan=[0 1];
E_omega_0=[0 0.0625];
[z, E_omega] = ode45(@odefun,zspan,E_omega);
E1_omega = E_omega(:, 1:end/2);
E2_omega = E_omega(:, end/2+1:end);
E1_t = ifft(E1_omega, [], 2);
E2_t = ifft(E2_omega, [], 2);
figure(101)
subplot(2, 2, 1)
[X, Y] = meshgrid(1:size(E1_omega, 2), z);
mesh(X, Y, abs(fftshift(E1_omega, 2)).^2);
subplot(2, 2, 2)
[X, Y] = meshgrid(1:size(E1_omega, 2), z);
mesh(X, Y,abs(fftshift(E2_omega, 2)).^2);
subplot(2, 2, 3)
[X, Y] = meshgrid(x, z);
mesh(X, Y,abs(fftshift(E1_t, 2)).^2);
subplot(2, 2, 4)
[X, Y] = meshgrid(x, z);
mesh(X, Y,abs(fftshift(E2_t, 2)).^2);
% g=angle(E_omega)
% K=unwrap(g)
figure(4)
plot(z,E_omega,'linewidth',4)
xlabel('z')
ylabel('phase (radian)')
  5 件のコメント
Jan
Jan 2018 年 11 月 19 日
編集済み: Jan 2018 年 11 月 19 日
Just a hint: While 5*10^-20 is a multiplication and an expensive power operation, 5e-20 is a cheap constant.
clear all removes all loaded functions from the RAM, such that relaoding the M-files from the slow disk wastes a lot of time. Prefer to use functions to keep the workspaces clean instead of this brutal clearing.
If you post the complete error message, the readers do not have to guess, which line is causing the problems.
In [X, Y] = meshgrid(x, z) what is the lower-case "x"?
asim asrar
asim asrar 2018 年 11 月 20 日
x is a mistake , it should be tau i.e. the propagation distance

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by