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!