When you call for with a vector as its loop variable definition, it iterates over the columns of the matrix you specify (not the elements.) So T does not take on the elements of [100; 1000; 10000] in turn, instead the loop iterates once with the whole column vector as T.
What does the / operator do when given a matrix and a vector as input? "x = B/A solves the system of linear equations x*A = B for x." So ProbDG is a vector such that x*[100; 1000; 10000] = 1.
T = [100; 1000; 10000];
x = 1/T;
x*T
x is not unique, three possible vectors x could be are [1/100, 0, 0], [0, 1/1000, 0], or [0, 0, 1/10000].
Since you wanted to compute the reciprocal of each element of T and subtract that result from 1, you need to use the ./ operator instead.
DGT=-log(-log(ProbDG))
end
Because ProbDG is not what you expected, DGT will not be either.
You could receive the results you expected by either making the T vector a row vector or using the ./ operator in the definition of ProbDG. If you make T a row vector the loop body will run three times, each on a scalar value. For scalar T the expressions 1/T and 1./T work the same way. Or you could just eliminate the loop and use the ./ operator as Adam suggested.
0 Comments
Sign in to comment.