matrix operations and vectorization
1 view (last 30 days)
Show older comments
Hi I would like a little help to construct in Matlab a fast way of carrying out the following computations.
Suppose that there are T simulation periods and t is the period of the simulation. In each period I compute the elements of three vectors u1, u2, u3 all vectors are of size (T,1). I also have a known row vector x = [A(t-5:t-1)' 1 kh(t-5:t-1)'] produced in every iteration (period t).
I would like to compute what is described describe in the attached picture. That is all the possible combinations (product terms) for each element of the vectors u's in each iteration period.
Can someone help me implement this on Matlab?
2 Comments
Stephen23
on 25 Apr 2015
The equation shown in the image does not mention u1, u2 or u3 anywhere, so it is not clear what these are used for.
Accepted Answer
Stephen23
on 25 Apr 2015
Edited: Stephen23
on 25 Apr 2015
>> a = [1,2,3];
>> b = [1,2,3,4];
>> bsxfun(@times, a(:), b)
ans =
1 2 3 4
2 4 6 8
3 6 9 12
Note that the orientation of the input vectors/matrices is significant. Then you can simply sum over the T values, which you seem to be generating in a loop.
3 Comments
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!