Asked by sanjiv kumar
on 12 Sep 2019

M= 100; % gain for Si and 50 for Ge

R_d= 75; % responsivity for Si and 35A/W for Ge

q= 1.6*10.^-19; % charge

F_noise = 0.5; % nosie figure 0f Si and 0.95 for Ge

I_d = 15 * 10.^-9; % dark Current for Si and 700nA for Ge

B_e = 5*10.^9; % bandwidth for Si and 0.2GHz for Ge

k_B = 1.38*10.^-23; % boltzmann constant

T = 298 ; % tamperature in kelvins

R = 10*10.^3; % APD load resistance

k = -40:20:80;

K_w = 1*10.^-3 * 10.^( k / 10);

Pr1 = (K_w*0.75*0.75*(exp(-0.003*25./cos(pi/36))) .* 0.01 .* cos(pi/36) ./ ((2*pi*25.^2)*(1-cos(pi/3))));

I_p= sqrt(M*R_d*Pr1); %average photocurrent

I_short= sqrt(2*q*I_p*M.^2*F_noise);

I_dark = sqrt(2*q*I_d*M.^2*F_noise*B_e);

I_thermal = sqrt((4*k_B*T/R)*B_e);

I_noise1 = sqrt(I_short1 + I_dark + I_thermal);

SNR1 = I_p.^2*M^2/I_noise1;

SNR_db1 = 1.*log(SNR1);

figure

plot(k,SNR_db1,'-ro')

Error using /

Matrix dimensions must agree.

Answer by Guillaume
on 12 Sep 2019

Accepted Answer

There doesn't appear to be any logic behind the choice of * vs .*, / vs ./, etc. If you don't understand the difference between the two and just try one or the other until it works, you're not going to go very far. Or if you don't know what is vector or scalar in your code, similarly, you'll have problems.

Few of the dotted operations in your expressions actually need to be dotted. But if you chose to dot the scalar expressions, then you should dot them all. Be consistent.

Also, note that a more concise way to write constants of the form 1.6*10^-19 (I removed the unnecessary dot) is 1.6e-19

As Adam said, you haven't told us what I_Short1 is, but it must be non-scalar for you to get an error. If so, your expressions should probably be:

SNR1 = I_p.^2 * M^2 ./ I_noise1;

Of course, I_noise1 must be a row vector with the same numbers of elements as K (7 elements).

By the way, why not:

K = -4:2:8; %why have it -40:20:80

K_w = 1e-3 * 10.^K; %if you're going to divide it by 10 on the next line

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 1 Comment

## Adam Danz (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/480104-matrix-mis-match#comment_745248

Sign in to comment.