Using the dms2degree Command Sequentially to Populate an Array using a Sub-routine
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
James Tursa
2019 年 6 月 27 日
編集済み: James Tursa
2019 年 6 月 27 日
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!