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!