matrix operations and vectorization
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Stephen23
le 25 Avr 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.
Réponse acceptée
Stephen23
le 25 Avr 2015
Modifié(e) : Stephen23
le 25 Avr 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!