Problem with non-existent variables
显示 更早的评论
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
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!