Use the elementwise division:
d1i=(2*R.*lambda) ./ (10.^(-2).*r1i);
You have used the elementwise operations exhaustively, even if they are not needed, because the operands are scalars only. But at the only location, where it is needed, the matrix division / is applied. I'd use:
d1i = 2 * R * lambda ./ (1e-2 * r1i);
d1i = 200 * R * lambda ./ r1i;
By the way, compare
with
The first is an expensive power operation, while the second is a cheap constant - and nicer. Then your code becomes:
U = [10 9.7 9.4 9.1 8.8 8.5 8.2 7.9 7.6 7.3 7.0 6.7 6.4 6.1 5.8 5.5 5.2 4.9 4.6 4.3 4.0];
h = 6.625e-34;
m = 9.109e-31;
e = 1.602e-19;
lambda = h ./ sqrt(2 * m * e * U * 1000);
R = 65e-3;
ri = [0.7 0.75 0.8 0.85 0.9 0.9 1.05 1.05 1.1 1.1 1.1 1.15 1.15 1.10 1.10 1.10 1.10 1.15 1.10 1.15 1.2; ...
0.75 0.75 0.85 0.95 1 1 1.05 1.1 1.1 1.1 1.1 1.15 1.2 1.2 1.25 1.25 1.25 1.3 1.3 1.3 1.35; ...
0.7 0.75 0.75 0.8 0.85 0.85 0.9 0.95 1 1 1 1 1.05 1.05 1.05 1.1 1.1 1.15 1.15 1.15 1.2];
ro = [1.2 1.3 1.35 1.4 1.4 1.45 1.5 1.55 1.55 1.6 1.6 1.67 1.67 1.75 1.75 1.8 1.9 1.9 2 2.05 2.1; ...
1.25 1.3 1.4 1.4 1.45 1.45 1.5 1.55 1.6 1.65 1.65 1.7 1.7 1.75 1.85 1.9 1.9 1.95 2 2.05 2.1; ...
1.2 1.25 1.3 1.35 1.4 1.45 1.5 1.5 1.55 1.6 1.6 1.65 1.7 1.7 1.75 1.8 1.85 1.9 1.95 2 2.05];
di = 200 * R * lambda ./ ri;
do = 200 * R * lambda ./ ro;
dinner = mean(di, 1)
douter = mean(do, 1)
Less chances for typos.
Best Answer