I got an equation similar to this : X-sin(thita). size(X) = 1x50 size(thita) = 1x180.
My output should be a matrix of 50x180. It could be done easily by using 2 for-loop but i am trying to find something more efficient. I tried bsxfun() but i could not manage it.
Thanks in advance

 채택된 답변

David Young
David Young 2014년 9월 12일
편집: David Young 2014년 9월 12일

0 개 추천

Convert X to a column vector. Then bsxfun will do what you want.
For example
X = rand(1, 50);
thita = rand(1, 180);
Xthitadiffs = bsxfun(@minus, X.', sin(thita)); % transpose on X makes column

추가 답변 (1개)

Mischa Kim
Mischa Kim 2014년 9월 12일

0 개 추천

Dimitrios, you mean something like
X = 1:50;
theta = (1:180)*pi/180;
mat = repmat(X',1,numel(theta)) - repmat(sin(theta),numel(X),1);

댓글 수: 1

David Young
David Young 2014년 9월 12일
It's a good idea to use .' rather than ' for transposing X, because ' takes the complex conjugate. We don't know for sure that X is always real.

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2014년 9월 12일

편집:

2014년 9월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by