Making my answer show in matrix form
Afficher commentaires plus anciens
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

Réponses (2)
KALYAN ACHARJYA
le 16 Fév 2020
Modifié(e) : KALYAN ACHARJYA
le 16 Fév 2020
for n=1:7
coordsX(n)= ; % Semicolon here
coordsY(n)= ; % Semicolon here
end
coordsX
coordsY
2 commentaires
Kirpa Khangura
le 16 Fév 2020
KALYAN ACHARJYA
le 16 Fév 2020
Welcome, do improve the code with pre-allocation.
fred ssemwogerere
le 16 Fév 2020
Modifié(e) : fred ssemwogerere
le 16 Fév 2020
% 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
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
