Question: Hello, I would like some help in debugging my code in MATLAB please. locatePlace.m: function RGB = locatePlace(longitude,latitude,name) % Makes a figure: world map with
Hello, I would like some help in debugging my code in MATLAB please.
locatePlace.m:
function RGB = locatePlace(longitude,latitude,name) % Makes a figure: world map with plotted point and title % Inputs: % longitude = signed longitude, deg (-177 to 178) % latitude = signed latitude, deg (-58 to 88) % name = placename (string) % Sign convention for longitudes and latitudes: % The prime meridian, which passes through Greenwich, % England, has longitude 0 deg. A longitude between % -180 and 0 deg is west of the prime meridian. A % longitude between 0 and +180 deg is east of the prime % meridian. A latitude between -90 and 0 deg is south % south of the equator. A latitude between 0 and +90 % is north of the equator. % How this function works: % The file topo.mat, a built-in MATLAB data file, % contains a matrix with 180 rows (one for % each integer-degree latitude -89 to 90) and 360 % columns (one for each integer-degree longitude % 0 to 359). Each element in the matrix is the % elevation above sea level in meters. This function % reorganizes columns in the matrix so that the columns % correspond to geographers' designation of longitudes: % -179 deg to +180 deg. Antarctica is removed because % it distorts badly in the sphere-to-flat transformation. % Negative elevations, assumed to be ocean, are made blue, % and positive elevations, assumed to be land, are made % white. A red disk is added at the specified longitude % and latitude. A title is added. load topo topo1(:,180:360) = topo(:,1:181); topo1(:,1:179) = topo(:,182:360); topo2(1:150,:) = topo1(31:180,:); % Antarctica removed topo3 = flipud(topo2); % top row becomes Arctic worldMap = zeros(150,360,3,'uint8'); worldMap(:,:,3) = 255; land = (topo3 > 0); worldMap(:,:,1) = 255*land; worldMap(:,:,2) = 255*land; row = round(90-latitude+1); column = round(180+longitude); worldMap(row-2:row+2,column-2:column+2,1) = 255; worldMap(row-2:row+2,column-2:column+2,2:3) = 0; RGB = insertText(worldMap,[180,130],name,'BoxColor','blue','TextColor','white'); end % locatePlace
main.m
myAnimation = 'Superpowers'; fps = 0.5; writerObj = VideoWriter(myAnimation,'MPEG-4'); writerObj.FrameRate = fps; open(writerObj); for n = fps frm = im2frame(locatePlace(-119.77,36.75,'Fresno, California')); writeVideo(writerObj, frm); frm1 = im2frame(locatePlace(23.601079,58.380226,'Muscat, Oman')); writeVideo(writerObj, frm1); frm2 = im2frame(locatePlace(-119.77,36.75,'Fresno, California')); writeVideo(writerObj, frm2); frm3 = im2frame(locatePlace(-119.77,36.75,'Fresno, California')); writeVideo(writerObj, frm3); end close(writerObj);?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
