Making my answer show in matrix form

14 ビュー (過去 30 日間)
Kirpa Khangura
Kirpa Khangura 2020 年 2 月 16 日
コメント済み: KALYAN ACHARJYA 2020 年 2 月 16 日
I have this code in a script and was trying to get the answer to come in a matrix form with all the coordsx in row1 and coord y in row 2 I keep getting answers for the x and y separately but need them in matrix form.
Thanks in advanc

回答 (2 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 2 月 16 日
編集済み: KALYAN ACHARJYA 2020 年 2 月 16 日
for n=1:7
coordsX(n)= ; % Semicolon here
coordsY(n)= ; % Semicolon here
end
coordsX
coordsY
  2 件のコメント
Kirpa Khangura
Kirpa Khangura 2020 年 2 月 16 日
thanks so much i was wondering if it was possible to put it in a format more like this
KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 2 月 16 日
Welcome, do improve the code with pre-allocation.

サインインしてコメントする。


fred  ssemwogerere
fred ssemwogerere 2020 年 2 月 16 日
編集済み: fred ssemwogerere 2020 年 2 月 16 日
% Try this
% preallocate an array "coords"
coords=zeros(2,7);
for n=1:7
coords(1,n)=-(xfactor*trav(n,4)+(dxdy(n,1)); % x-coordinates appear in row 1 of an array: "coords"
coords(2,n)=-(yfactor*trav(n,4)+(dxdy(n,2)); % y-coordinates appear in row 2 of the same array: "coords"
end

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by