I'd like to multiply a random number vector PT(n)=rand(1,n) by a matrix M(mxn) but want to have a different random vector for each column multiplication. Is it possible in Matlab?
E.g. PT=rand(1,4);
`PT*(1 0 0 0;... 0 0 0 1;... 0 1 0 0;... 0 0 0 1); but where PT changes for each column multiplication. The only way I can think of is make PT=rand(4,4)and then take diag(PT*M) but it's very expensive if my matrix M is large.
Any thoughts?
Cheers
Suplemental using @Nasser arrayfun code takes 3 times longer than a for loop. I see it's normal but why the big difference?
1xnvector by amxnmatrix. And wouldn't what you describe just result in a random vector anyway?