How to build a new matrix
1 回表示 (過去 30 日間)
古いコメントを表示
I have a matrix
a = [4;6;8;2;8;2];
And I want it to be like:
b = [7;8;11;12;15;16;3;4;15;16;3;4];
Matrix b is calculated based on following formula:
7 = 4*2-1
8 = 4*2
11 = 6*2-1
12 = 6*2
15 = 8*2-1
16 = 8*2
3 = 2*2-1
4 = 2*2
15 = 8*2-1
16 = 8*2
3 = 2*2-1
4 = 2*2
1 件のコメント
Titus Edelhofer
2014 年 10 月 29 日
Hi,
I would suggest to take a look at http://www.mathworks.com/matlabcentral/answers/8626-how-do-i-get-help-on-homework-questions-on-matlab-answers
Titus
採用された回答
Mischa Kim
2014 年 10 月 29 日
Something like
b = reshape(bsxfun(@minus,2*repmat(a,1,2),[1 0])',1,[])
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!