How to build a ''growing" matrix

1 回表示 (過去 30 日間)
Sebastian Ciuban
Sebastian Ciuban 2014 年 4 月 13 日
コメント済み: Image Analyst 2014 年 4 月 13 日
In my example I have:
variable "i" (size 1x1) and R (size 3x3)
R = 1 0 0
0 cos(i) sin(i)
0 -cos(i) cos(i)
Now, how should I build "R" if my variable "i" has size 1 x n?
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 13 日
What is the size of R?
Sebastian Ciuban
Sebastian Ciuban 2014 年 4 月 13 日
Well in the simple case lets say:
i=1
R=1 0 0
0 cos(i) sin(i)
0 -cos(i) cos(i)
But what if i=[1 3 5 5]. How I can make R to be computed for all the values of i?

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2014 年 4 月 13 日
cos(i) will be an array if i is an array. So that means that the elements of R must be cells since all elements of R are not the same size. The firs row and column of R are 1x1 while the lower right elements are 1 x 4. I really think you should avoid this route, but if you insist, start your study of cells here in the FAQ: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F. You'd probably be better off making R a 3D array though, with each plane of R being computed for a different value of i. Let us know which approach you want to take. If you don't know , then let us know what you plan on doing with R once you have it.
  2 件のコメント
Sebastian Ciuban
Sebastian Ciuban 2014 年 4 月 13 日
Shall I write my code and explain what is my final purpose?
Image Analyst
Image Analyst 2014 年 4 月 13 日
Yes, why wouldn't you?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by