making a new matrix with the other matrix elements.

1 回表示 (過去 30 日間)
Ayob
Ayob 2013 年 4 月 21 日
I want to build a matrix with the element of the other matrix in a special condition. my first matrix is something normal for example: A=[8 11 9 5]
but second matrix or needed one is something different that I call it B matrix here ,every three elements of matrix B are made up of one element of matrix A.
For example,if the second element of matrix A is 8,we know that 4th,5th and 6th element of matrix B are 3*(11)-2 , 3*(11)-1 and 3*(11)
There are many solutions to this problem for example I can do this:
A=[8 11 9 5] B=[3*A(1)-2 3*A(1)-1 3*A(1) 3*A(2)-2 3*A(2)-1 3*A(2) .... ]
but this is an ugly form solution and may matrix A and B are changing size every loop, I searching for MATLAB special solution in matrix calculations which are fast and need less code writing.

採用された回答

Iman Ansari
Iman Ansari 2013 年 4 月 21 日
Hi.
A=[8 11 9 5 10 15];
B=[3*A-2; 3*A-1; 3*A];
B=B(:)'
  1 件のコメント
Ayob
Ayob 2013 年 4 月 21 日
Best answer could be given.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by