Do I need nested loops?
Afficher commentaires plus anciens
I am trying to create a small script that will allow me to expand the perimeter based off coordinates. The program is running through the variables correctly when I look at the workspace, but I can't get it to write the results to the structure multiple times. It will only write to the structure once. Am I missing a nested loop?
load 'lat_lon.mat'
new_coord = [];
for i = 1:length(lat_lon)
1
new_coord.Lat = [lat_lon(:,[1])];
new_coord.Lon = [lat_lon(i:,[2])];
2
%Finds the radius of the Earth at given latitude
radius = 6372 * cos(lat_lon(i,[1])/180 * pi)
3
%Converts given perimeter expansion to degrees
lat_nat_deg = nm2deg(3.5, radius);
new_coord.lat_exp = [lat_nat_deg];
nat_deg = nm2deg(3.5);
new_coord.lon_exp = [nat_deg];
4
new_coord.latitude = [lat_lon(i,[1]) + lat_nat_deg];
5
new_coord.longitude = [lat_lon(i,[2]) + nat_deg]
end
The lat_lon.mat is :
Lat_Long = [60.8427194, -042.7969500; ...
60.8646972, -042.5323889; ...
60.7640417, -042.5178639; ...
60.5882139, -042.8185056; ...
60.8080111, -042.8507500; ...
60.8069889, -042.8374167; ...
60.8083028, -042.8278361; ...
60.8114056, -042.8186167; ...
60.8152306, -042.8117389; ...
60.8203694, -042.8055667; ...
60.8256528, -042.8013611; ...
60.8315167, -042.7985083; ...
60.8374056, -042.797078; ...
60.8427194, -042.7969500];
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements 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!