MATLAB Vectorization help?
I have the indexes of an array in an array. While that may sound confusing, all I want to do is take the array
[ 1 2 .004
2 3 .02
3 4 .7
2 4 .01
4 5 .006]
and create the array
[0 .004 0 0 0
0 0 .02 0 0
0 0 0 .7 0
0 0 0 0 .006]
elegantly in MATLAB without for loops.
Ha! Thanks, that's a little TOO elegant, this was just an example I made up . . . the array indices are not necessarily along the diagonal, this just happened to be a special case. Say the first row of the first matrix was 1 4 .004 . . . What I'm looking for is a faster version of this
for i=1:length(M(:,1))
L(M(i,1),M(i,2))=M(i,3)
end
Ha! Thanks, that's a little TOO elegant, this was just an example I made up . . . the array indices are not necessarily along the diagonal, this just happened to be a special case. Say the first row of the first matrix was 1 4 .004 . . . What I'm looking for is a faster version of this
for i=1:length(M(:,1))
L(M(i,1),M(i,2))=M(i,3)
end
You're also right in that I didn't mean to delete any of the rows . . .