can anyone explain what this piece of code do?

 채택된 답변

Star Strider
Star Strider 2014년 10월 15일

1 개 추천

The first line converts a (Nx3) matrix ‘center’ where ‘center(:,3)’ is a vector of angles, apparently defining vectors in those directions with a constant length of 8, and converts it to Cartesian coordinates.
The second line (using the quiver function) plots arrows with the first two columns of ‘center’ defining the the origins of the arrows and ‘u’ and ‘v’ (calculated in the first line) defining their directions and lengths.

댓글 수: 3

Vinay Kumar
Vinay Kumar 2014년 10월 16일
Thank you Star Strider. what the following signify? c=[];
My pleasure!
The assignment:
c = [];
sets variable ‘c’ equal to the empty matrix. It is useful if, for instance, you want to add other elements to it in a loop, for example:
for k = 1:10
c = [c k];
end
It is preferable to do what is known as ‘preallocation’ rather than concatenation, but in some instances, preallocation is not possible and serial concatenation is the only way to create a variable array.
Vinay Kumar
Vinay Kumar 2014년 10월 16일
Thank you Star Strider

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Vector Fields에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2014년 10월 15일

댓글:

2014년 10월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by