Is there any other way to re-code this function (perhaps with for loop):
mmm = [2;3;4;8;9;11;13;14;15;16];
Dmm = zeros(2*size(mmm),1);
Dmm = reshape(bsxfun(@minus,2*repmat(mmm,1,2),[1 0])',1,[])'

댓글 수: 1

Adam
Adam 2014년 11월 3일
There are always a multitude of different ways to program something and pretty much always a loop equivalent to vectorisation and bsxfun. The for loop equivalent should be easy enough to define though it's not obvious why you would want to - people usually wish to go in the other direction!

댓글을 달려면 로그인하십시오.

 채택된 답변

per isakson
per isakson 2014년 11월 3일
편집: per isakson 2014년 11월 3일

0 개 추천

Is this Cody?
reshape( permute( cat( 2, 2*mmm-1, 2*mmm ), [2,1] ), [],1 )
or with fewer characters
reshape( permute( [2*mmm-1,2*mmm], [2,1] ), [],1 )
or
reshape( [2*mmm-1,2*mmm]', [],1 )

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

Moe
2014년 11월 3일

편집:

2014년 11월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by