matrix operations and vectorization
조회 수: 1 (최근 30일)
이전 댓글 표시
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
Stephen23
2015년 4월 25일
The equation shown in the image does not mention u1, u2 or u3 anywhere, so it is not clear what these are used for.
채택된 답변
Stephen23
2015년 4월 25일
편집: Stephen23
2015년 4월 25일
>> 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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!