getting error as "Data dimensions must agree." can someone help me resolve this
    4 ビュー (過去 30 日間)
  
       古いコメントを表示
    
getting error for my code as:-
Error using mesh (line 58)
Data dimensions must agree.
Error in odefun1 (line 79)
mesh(X, Y,abs(fftshift(E1_t, 2)).^2);
function is=>
function dE_omega_dz = odefun(z, E_omega,~,~)
dE_omega_dz=zeros(length(E_omega),1);
z=z*10^5;
display(z);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda1=800*10^-9;
c=3*10^8
lambda2=400*10^-9;
y= 28.78076 %22.4431   %22.39002159      %20:0.25:50  22.39002159     22.443 
ne2=1.5687;
no2=1.6934;
no1=1.6614;
r22=2.1*10^-12                   %electro-optic coefficient in m/v
j=1;
t=1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for Ez=0:50*10^3:85*10^5
noE= no1*(1-0.5*no1^2*r22*Ez)
NEE= ((((sin(y)).^2)/((ne2)^2))+(((cos(y))^2)/((no2)^2)))^-0.5
deltak=-(((4*3.14*(NEE-noE))/ lambda1)) 
Dk(j)=(deltak);
% Dk=deltak;
V=(Ez*4)/10^6
V1(t)=V;
display(Dk);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
l=800*10^-9;        % lambda
c=30*10^8;
pi=3.1415926535;
n_2=6.6508*10^-20;
L_NL=6.8286e-18; 
LGVM=0.6*10^-3;
I0=0.4*10^11;
% 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);
figure(786)
x=-300*10^-15:1*10^-15:300*10^-15;
plot(x,fftshift(E1_t.^2));
% pause(0.2)
N=max(size(E1_t));
to=120e-15/1.655; % initial pulse widthin second
dt=1/120e-15;
dw=1/N/dt*2*pi;
%dw=2*pi*c/l;
 w=(-1*N/2:1:N/2-1)*dw;
% and calculate the derivatives:
dE_omega_dz(1:length(E_omega)/2) = fft(1i*conj(E1_t).*E2_t.*exp(1i*Dk(j).*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(j).*z)....
    + 1i*4*pi*n_2*I0*L_NL/l*(2*abs(E1_t.^2 + ...
    abs(E2_t.^2)).*E1_t));
t=t+1;
j=j+1;
end
end
CALLING FUNCTION -
function dE_omega_dz = odefun(z, E_omega,~,~)
dE_omega_dz=zeros(length(E_omega),1);
z=z*10^5;
display(z);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda1=800*10^-9;
c=3*10^8
lambda2=400*10^-9;
y= 28.78076 %22.4431   %22.39002159      %20:0.25:50  22.39002159     22.443 
ne2=1.5687;
no2=1.6934;
no1=1.6614;
r22=2.1*10^-12                   %electro-optic coefficient in m/v
j=1;
t=1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for Ez=0:50*10^3:85*10^5
noE= no1*(1-0.5*no1^2*r22*Ez)
NEE= ((((sin(y)).^2)/((ne2)^2))+(((cos(y))^2)/((no2)^2)))^-0.5
deltak=-(((4*3.14*(NEE-noE))/ lambda1)) 
Dk(j)=(deltak);
% Dk=deltak;
V=(Ez*4)/10^6
V1(t)=V;
display(Dk);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
l=800*10^-9;        % lambda
c=30*10^8;
pi=3.1415926535;
n_2=6.6508*10^-20;
L_NL=6.8286e-18; 
LGVM=0.6*10^-3;
I0=0.4*10^11;
% 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);
figure(786)
x=-300*10^-15:1*10^-15:300*10^-15;
plot(x,fftshift(E1_t.^2));
% pause(0.2)
N=max(size(E1_t));
to=120e-15/1.655; % initial pulse widthin second
dt=1/120e-15;
dw=1/N/dt*2*pi;
%dw=2*pi*c/l;
 w=(-1*N/2:1:N/2-1)*dw;
% and calculate the derivatives:
dE_omega_dz(1:length(E_omega)/2) = fft(1i*conj(E1_t).*E2_t.*exp(1i*Dk(j).*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(j).*z)....
    + 1i*4*pi*n_2*I0*L_NL/l*(2*abs(E1_t.^2 + ...
    abs(E2_t.^2)).*E1_t));
t=t+1;
j=j+1;
end
end
回答 (1 件)
  per isakson
      
      
 2019 年 1 月 3 日
        Are  odefun1 and odefun the same function?
Proposal: Set a breakpoint at the line that throws the error. Run the code again. At the breakpoint, inspect the values of the variables which occur in the error throwing line. 
0 件のコメント
参考
カテゴリ
				Help Center および File Exchange で Electromechanical についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


