Using the dms2degree Command Sequentially to Populate an Array using a Sub-routine
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
James Tursa
el 27 de Jun. de 2019
Editada: James Tursa
el 27 de Jun. de 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 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!