I have the following:
n = 3;
m = 5;
ww = RandomReal[{0, 0.1}, {n, n}];
uu = RandomReal[{0, 1}, {m, n}];
pp = RandomReal[{0, 1}, {n, n}];
ss = RandomInteger[{0, 5}, {m, n}];
Grid[{{"ww", "uu", "pp", "ss"}, {ww // TableForm, uu // TableForm,
pp // TableForm, ss // TableForm}}, Spacings -> {5, 2},
Dividers -> All]
where I would like to look at every element of matrix ss and produce a matrix tt, with zeroes at the locations in ss which have zeroes, and in all other positions do the following:
tt = (-1/Subscript[ww, m]) Log[(1 - uu)/(Subscript[pp, m - 1])],
where Subscript[ww, m] is the value at index of ww matrix and where Subscript[pp, m - 1] is the value at index-1 of pp matrix.
So for example if the first value ever read from matrix ss happens to be 2, then value taken from matrix ww would be from the row 2, but from pp would be from row 1.
Also how to tell difference between a 0 as a valid value from within the matrix elements to end of matrix if I do not know the actual size of the matrix beforehand?
Given the data as above, tt matrix would be like this:







ttis intended to do. As it is presentedtthas a small syntax error, the training comma. SecondlySubscript[ww,m]is a formatted object withwwdisplayed with a typographical subscriptm. Your text suggests that it is the value atindexofww. Doesindexrefer tom? If the value inssis 2 then the "value" to be taken fromwwwould be from row 2. Do you mean all of row 2 or some particular element in row 2, if so which element ? – image_doctor Nov 8 '12 at 14:30ttof zeroes at each position in whichsshas a zero and a scalar valuettat other positions? – image_doctor Nov 12 '12 at 14:06