Using the dms2degree Command Sequentially to Populate an Array using a Sub-routine
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How to I use the dms2degree (mapping toolbox) command for array elements using a for statement?
Eg.
n=6
A = [180 342 350 121 125 179; 0 54 41 16 23 59; 3 49 18 20 13 50]'
B (6,1) = zeros
for i =1:n
tempVal = dms2degree(A(i,1), (i,2), (i,3)) % Syntax error when trying to specify row & element of A
% Populates degree.decimals into array B iteratively
B(i,1) = tempVal
end
Thanks
0 commentaires
Réponses (2)
James Tursa
le 27 Juin 2019
Modifié(e) : James Tursa
le 27 Juin 2019
With a for-loop, you need to use A in all of your indexing and use the [ ] brackets to form a vector input (and spell the function name correctly). E.g.,
tempVal = dms2degrees([A(i,1), A(i,2), A(i,3)])
Or just
tempVal = dms2degrees(A(i,1:3))
Also, you need to pre-allocate B differently:
B = zeros(n,1);
But of course you can do the whole thing without a for-loop:
B = dms2degrees(A);
0 commentaires
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!