matrix operations and vectorization
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Stephen23
am 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.
Akzeptierte Antwort
Stephen23
am 25 Apr. 2015
Bearbeitet: Stephen23
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!