Problem with non-existent variables
Show older comments
I try to write a code for extract gps info for my study. I used them in a xls file. I write the code below but have problem with non-existent values. Some of the photos are not have gps info, I want to give 0 values for these photos's info but I couldn't do that. Btw, I am novice programmer.
list = dir('*.JPG');
[m n]= size(list);
sz = [m 3];
varTypes = { 'string','string','string'};
varNames = {'ImageName','Lat','Lng'};
T = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
for i = i:m
disp(list(i).name);
imgName = list(i).name;
info = imfinfo(imgName);
if isfield(info.GPSInfo)
lat = info.GPSInfo.GPSLatitude;
lng = info.GPSInfo.GPSLongitude;
strLat = lat(1) + "," + lat(1)+ "," + lat(3);
strLng = lng(1) + "," + lng(1)+ "," + lng(3);
T(i,:) = {imgName, strLat,strLng};
else
lat = [0 0 0];
lng = [0 0 0];
strLat = lat(1) + "," + lat(1)+ "," + lat(3);
strLng = lng(1) + "," + lng(1)+ "," + lng(3);
T(i,:) = {imgName, strLat,strLng};
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!