getting error for my program as " Error using * Inner matrix dimensions must agree." on line 42 . can someone help me resolve this issue?

6 ビュー (過去 30 日間)
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:0.01*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')
L=800*10^-9;
dt=1/t;
% dt=10^-4.9/t;
c=3*1e8;
z=30*10^-3;
deff=2.064*10^-12;
pi=3.1415926535;
esn=8.854*10^-12
I0=30*10^13;
E0=sqrt(Pi); %for ii=0.1:0.1:(s/10) %1*10^-7:1*10^-7:s %different fiber lengths
E1=E0*exp(-(tau/t).^2); % generation of an gaussian input pulse
subplot(2,1,1);
plot(tau,abs(E1).^2); % graph of input pulse
title('Input Pulse'); xlabel('Time in ps'); ylabel('intensity');
grid on;
hold on;
N=max(size(E1));
dw=((1/N)/dt)*2*pi
j=1;
k=1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for Dk=0:500:60000;
t1=[0.000312258194071092];
t2=[0.000312258194068605]
Lnll=(Dk)./(t1*t2*abs(I0^2))*10
Lnl(j)=Lnll;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
p1=800*10^-9;
p2=p1/2;
n1=1.6551;
n2=1.6749;
n33=(4*pi*z*deff^2)/(c*esn*L*n1^2*n2*Dk.*z)
n3(k)=n33;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
w3=dw*(-N/2:1:N/2-1);
n3=9.1514*10^-20;
P = (-1i*conj(E1).*E1.^2.*w3.*deff)/(Dk.*n3.*c)+ 1i*2*pi*(n3.*I0)*(Lnl./L)*((abs(E1)).^2).*E1 +...
+ 1i*4*pi*(n3.*I0)*(Lnl./L).*((-w3.*deff.*E1.^2*exp(-1i*Dk.*z))/(Dk.*n3.*c)).^2.*E1;
pause(0.1)
subplot(2,1,2);
plot(tau,abs(P).^2);
caption1 = sprintf('Output pulse with Delta K = %.3f', Dk);
title(caption1, 'FontSize',10);
xlabel('Time in ps'); ylabel('intensity');
j=j+1;
k=k+1;
end
hold on;
grid on;
  2 件のコメント
KSSV
KSSV 2018 年 11 月 13 日
編集済み: KSSV 2018 年 11 月 13 日
YOur Lnl is 1*2..it is chaging in a loop..so you need add index into it...use Lnl(j) instead of Lnl. Still, your code can be written more effectively.
asim asrar
asim asrar 2018 年 11 月 13 日
thenks for the response sir , will check and do it as directed by you

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

採用された回答

KSSV
KSSV 2018 年 11 月 13 日
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:0.01*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')
L=800*10^-9;
dt=1/t;
% dt=10^-4.9/t;
c=3*1e8;
z=30*10^-3;
deff=2.064*10^-12;
pi=3.1415926535;
esn=8.854*10^-12
I0=30*10^13;
E0=sqrt(Pi); %for ii=0.1:0.1:(s/10) %1*10^-7:1*10^-7:s %different fiber lengths
E1=E0*exp(-(tau/t).^2); % generation of an gaussian input pulse
subplot(2,1,1);
plot(tau,abs(E1).^2); % graph of input pulse
title('Input Pulse'); xlabel('Time in ps'); ylabel('intensity');
grid on;
hold on;
N=max(size(E1));
dw=((1/N)/dt)*2*pi
j=1;
k=1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for Dk=0:500:60000
Dk
t1=[0.000312258194071092];
t2=[0.000312258194068605]
Lnll=(Dk)./(t1*t2*abs(I0^2))*10
Lnl(j)=Lnll;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
p1=800*10^-9;
p2=p1/2;
n1=1.6551;
n2=1.6749;
n33=(4*pi*z*deff^2)/(c*esn*L*n1^2*n2*Dk.*z) ;
n3=n33;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
w3=dw*(-N/2:1:N/2-1);
n3=9.1514*10^-20;
P = (-1i*conj(E1).*E1.^2.*w3.*deff)./(Dk.*n3.*c)+ 1i*2*pi*(n3.*I0).*(Lnl(j)./L).*((abs(E1)).^2).*E1 +...
+ 1i*4*pi*(n3.*I0).*(Lnl(j)./L).*((-w3.*deff.*E1.^2.*exp(-1i*Dk.*z))./(Dk.*n3.*c)).^2.*E1;
pause(0.1)
subplot(2,1,2);
plot(tau,abs(P).^2);
caption1 = sprintf('Output pulse with Delta K = %.3f', Dk);
title(caption1, 'FontSize',10);
xlabel('Time in ps'); ylabel('intensity');
j=j+1;
k=k+1;
end
hold on;
grid on;

その他の回答 (2 件)

Stephen23
Stephen23 2018 年 11 月 13 日
編集済み: Stephen23 2018 年 11 月 13 日
The error occurs here:
1i*2*pi*(n3.*I0)*(Lnl./L)*((abs(E1)).^2)
^^^^^^^^^^^^^^^^ % scalar
^^^^^^^^ % 1x2
^^^^^^^^^^^^^ % 1x60001
What do you expect to happen when you matrix multiply a 1x2 vector with a 1x60001 vector?

madhan ravi
madhan ravi 2018 年 11 月 13 日
change * to .* and / to ./

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by