can anyone explain what this piece of code do?

1 回表示 (過去 30 日間)
Vinay Kumar
Vinay Kumar 2014 年 10 月 15 日
コメント済み: Vinay Kumar 2014 年 10 月 16 日
[u,v] = pol2cart(center(:,3),8);
quiver(center(:,2),center(:,1),u,v,0.3,'g');

採用された回答

Star Strider
Star Strider 2014 年 10 月 15 日
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 件のコメント
Star Strider
Star Strider 2014 年 10 月 16 日
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 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by