PDA

查看完整版本 : Matlab code Unable to perform assignment because the left and right sides have a different number of


poster
2019-11-27, 13:24
<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>



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