MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   Matlab code Unable to perform assignment because the left and right sides have a different number of (https://www.labfans.com/bbs/showthread.php?t=22185)

poster 2019-11-27 13:24

Matlab code Unable to perform assignment because the left and right sides have a different number of
 
<p>I ma try to plot some signal using Matlab I wrote the code
But when I try to run it it through an error **Unable to perform assignment because the left and right sides have a different number of elements **
I can't figure what is the problem. I need to understand how can I solve it
Can some one help me get over this problem </p>

<pre><code>lambda= 30*10.^-6;%Wavelength 5um
L=10*10.^-9;
c=3*10.^8;
q= 1.6*10.^-19;
kb= 1.38*10.^-23;
T= 298;
Vf= 10.^6;
hev= 6.582*10.^-16;
kbev= 8.6*10.^-5;
tau= 6*10.^-12;
h= 1.055*10.^-34;
d= 80*10.^-9;
n=1;
eps=(n)^2;
fc = c/lambda; % Actual Frequency of light [THz]
fsamp=fc*10; %sampling frequency
fs=1/fsamp; %Unit Time in [fs]
Ls=1000; %Length of signal
s=5e-13;%% Pulse duration, s=8e-15;
ts=(0:Ls-1)*fs; %time base
t0 = max(ts)/2; % Used to centering the pulse
Egauss=(exp(-((ts-t0)-50e-15).^2/(2*s)^2)).*exp(-1i*2*pi*fc*(ts-t0));
figure(1)
plot(ts,real(Egauss),'b');
title('Gaussian Pulse in Time Domain');
xlabel('Time(s)');
ylabel('Amplitude');
ylim([-1 1])

NFFT = 2^nextpow2(Ls);
X = fft(Egauss,NFFT)/Ls;
Pxx=X.*conj(X)/(NFFT*NFFT); %computing power with proper scaling
freq = fsamp*linspace(0,1,NFFT); % (full range) Frequency Vector
figure(2)
plot(freq, abs(X))
title('FFT of the Gaussian Pulse');
xlabel('Frequency (Hz)')
ylabel('Magnitude |X(f)|');
xlim([8.8e13 9.2e13
ii=0;
for NN = 8.8:0.01:9.2
ii = ii+1;

NNN=NN*10^13;

w0=2*pi*(fc+NNN);

lamda0=c/fc;

ko=2*pi/lamda0;

n0= 10^15;

mu= hev*Vf*(pi*n0).^.5;

sig= 1i*q.^2*kb*T*(mu/(kbev*T)+2*log(exp(-mu/(kbev*T))+1))./(pi*h.^2*(w0+1i/tau));
sigma=sig.';
wantedvalue=sig;

dispersion=d^-1*acos((cos(d*(eps)^.5*w0/c)-1i*Z0*.5*(eps)^-.5*sin(d*(eps)^.5*w0/c).*sigma));
dis(ii)=dispersion;

Beta(ii)=real(dispersion);
Alfa(ii)=abs(imag(dispersion));
%X1=(abs(X)).';

Adot=X(ii).*exp(-1i*Beta.*L).*exp(-Alfa.*L);

AAA(ii)=Adot;
end
figure(3)
plot(freq, abs(AAA))```
</code></pre>



[url=https://stackoverflow.com/questions/59063484/matlab-code-unable-to-perform-assignment-because-the-left-and-right-sides-have-a]More answer...[/url]


所有时间均为北京时间。现在的时间是 21:21

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.