I have a dataset with countries and lat/lon columns. I want to measure the distance between the countries. I used the distance function from the mapping toolbox and a for loop to get every single country.
I’m struggling with saving the results from the for loop. I’m overwriting my results. I want to save every run from the for loop as a single column, basically append the results from every run. Does anyone have an efficient/better way to save the results? I would really appreciate your help in advance. I attached the data example and my code
Data = readtable('Test.xlsx');
Distance = deg2sm(distance([Data.lat(i) Data.lon(i)], [Data.lat(1:end) Data.lon(1:end)]));