{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-06T14:01:22.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-04-06T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":44882,"title":"Opposite point of the earth, what is the antipodal of a point ?","description":"Given two strings(lat and long) that represent the geographic coordinates of a point in the earth, you have to find out what is the opposite or most farthest point of the earth from that point(antipodal).  \r\n The strings will be 'r.dd C', where r is the real part, dd(the mantissa in decimal, not in minutes and dd can be present or not with the form dd,d or '\u003cnothing\u003e', equal the point(.)) and C the cardinal point (S,N,E or W). \r\nYou have to return two strings (lat and long) with the same format that the input.\r\n\r\n*Extra question:* What is the opposite point of north pole? And why is not possible to calculate it by this method ?\r\n\r\nSuppose the earth is spherical, not flat (Lol)","description_html":"\u003cp\u003eGiven two strings(lat and long) that represent the geographic coordinates of a point in the earth, you have to find out what is the opposite or most farthest point of the earth from that point(antipodal).  \r\n The strings will be 'r.dd C', where r is the real part, dd(the mantissa in decimal, not in minutes and dd can be present or not with the form dd,d or '\u0026lt;nothing\u0026gt;', equal the point(.)) and C the cardinal point (S,N,E or W). \r\nYou have to return two strings (lat and long) with the same format that the input.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExtra question:\u003c/b\u003e What is the opposite point of north pole? And why is not possible to calculate it by this method ?\u003c/p\u003e\u003cp\u003eSuppose the earth is spherical, not flat (Lol)\u003c/p\u003e","function_template":"function [lat_o,long_o] = opposite_earth_point(lat,long)\r\n  [lat_o long_o] = [lat long];\r\nend","test_suite":"%% \r\n%Mathworks headquarters\r\nlat = '42.3 N';\r\nlong = '71.37 W';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct = '42.3 S';\r\nlong_o_correct = '108.63 E';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))\r\n\r\n%% \r\n%San Antonio\r\nlat = '29.31 N';\r\nlong = '98.46 W';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct = '29.31 S';\r\nlong_o_correct= '81.54 E';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))\r\n\r\n%%\r\n%My city \r\nlat = '32.9 S';\r\nlong = '68.82 W';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct= '32.9 N';\r\nlong_o_correct = '111.18 E';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))\r\n\r\n%%\r\n%Big Ben \r\nlat = '51.5 N';\r\nlong = '0.12 W';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct= '51.5 S';\r\nlong_o_correct = '179.88 E';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))\r\n\r\n%%\r\n%Wellington\r\nlat = '41.27 S';\r\nlong = '174.78 E';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct= '41.27 N';\r\nlong_o_correct = '5.22 W';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))\r\n\r\n%%\r\n%Some point of Brasil\r\nlat = '1 S';\r\nlong = '50 W';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct= '1 N';\r\nlong_o_correct = '130 E';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))\r\n\r\n%%\r\n% Some point near to Moscú\r\nlat = '55 N';\r\nlong = '37 E';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct= '55 S';\r\nlong_o_correct = '143 W';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":289312,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":18,"test_suite_updated_at":"2019-04-18T18:26:43.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-04-18T18:22:19.000Z","updated_at":"2026-03-16T13:49:41.000Z","published_at":"2019-04-18T18:22:19.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two strings(lat and long) that represent the geographic coordinates of a point in the earth, you have to find out what is the opposite or most farthest point of the earth from that point(antipodal). The strings will be 'r.dd C', where r is the real part, dd(the mantissa in decimal, not in minutes and dd can be present or not with the form dd,d or '\u0026lt;nothing\u0026gt;', equal the point(.)) and C the cardinal point (S,N,E or W). You have to return two strings (lat and long) with the same format that the input.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExtra question:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e What is the opposite point of north pole? And why is not possible to calculate it by this method ?\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the earth is spherical, not flat (Lol)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2497,"title":"Distance between two GPS Coordinates","description":"A problem that arises when performing geographically weighted regression is determining the distance between GPS coordinates. GIS (geographical information system) data is usually reported as a function of latitude and longitude.\r\nA common form of GIS data is a CSV file of latitude, longitude, z triples, where z is some quantity that varies with space.\r\nAs a prelude to interpolation, the distance between a given point and every other given point in an area needs to be calculated.\r\nGiven a set of GPS coordinates, return the distance (in miles) between each point and every point around it using the haversine formula ( http://en.wikipedia.org/wiki/Haversine_formula ) and taking the radius of Earth to be 3959 miles.\r\nSee Test Suite for Examples","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 204px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 102px; transform-origin: 407px 102px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 368.5px 8px; transform-origin: 368.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA problem that arises when performing geographically weighted regression is determining the distance between GPS coordinates. GIS (geographical information system) data is usually reported as a function of latitude and longitude.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 373.5px 8px; transform-origin: 373.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA common form of GIS data is a CSV file of latitude, longitude, z triples, where z is some quantity that varies with space.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 366.5px 8px; transform-origin: 366.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAs a prelude to interpolation, the distance between a given point and every other given point in an area needs to be calculated.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 371px 8px; transform-origin: 371px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a set of GPS coordinates, return the distance (in miles) between each point and every point around it using the haversine formula (\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ehttp://en.wikipedia.org/wiki/Haversine_formula\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 156px 8px; transform-origin: 156px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e ) and taking the radius of Earth to be 3959 miles.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 88px 8px; transform-origin: 88px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSee Test Suite for Examples\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function dist = procGPS(coords)\r\n\r\nend","test_suite":"%%\r\ncoords = [\r\n47.7891\t-103.074\r\n47.7885\t-103.051\r\n47.7598\t-103.055\r\n47.76\t-103.055\r\n47.761\t-103.055];\r\ndist_correct = [\r\n   0.00000   1.06856   2.20846   2.19580   2.13270\r\n   1.06856   0.00000   1.99178   1.97802   1.90924\r\n   2.20846   1.99178   0.00000   0.01382   0.08292\r\n   2.19580   1.97802   0.01382   0.00000   0.06910\r\n   2.13270   1.90924   0.08292   0.06910   0.00000];\r\nassert(abs(sum(sum((procGPS(coords)-dist_correct))))\u003c0.005*max(max(dist_correct)))\r\n\r\n%%\r\ncoords = [\r\n48.9803\t-103.808\r\n48.98031 -103.808\r\n48.9806\t-103.765\r\n48.9806\t-103.764\r\n48.9534\t-103.743\r\n48.9809\t-103.785\r\n48.9822\t-103.802\r\n48.2269\t-102.295\r\n48.2559\t-102.337\r\n48.2556\t-102.311\r\n48.2557\t-102.36\r\n48.2557\t-102.359\r\n48.9818\t-103.231\r\n48.8639\t-103.507\r\n48.8804\t-103.51\r\n48.8648\t-103.529\r\n48.7935\t-103.401\r\n48.8379\t-103.715\r\n48.63282 -103.492268];\r\n\r\ndist_correct = [\r\n0\t0.000690976\t1.950155232\t1.995502612\t3.485510848\t1.043867842\t0.302111766\t86.53754762\t83.78510566\t84.75282145\t82.9534702\t82.98989215\t26.16671135\t15.85736704\t15.18721355\t14.97174021\t22.55114901\t10.70767068\t27.98081693\r\n0.000690976\t0\t1.950147814\t1.995495354\t3.485879124\t1.043840523\t0.301812113\t86.53795777\t83.78551307\t84.75322419\t82.95388198\t82.99030374\t26.16670599\t15.85771634\t15.18752642\t14.97210747\t22.55154299\t10.70830547\t27.98140911\r\n1.950155232\t1.950147814\t0\t0.045349749\t2.12797696\t0.907229104\t1.681552044\t84.98895345\t82.23092177\t83.18867303\t81.40875472\t81.44476589\t24.21656659\t14.22106846\t13.48832542\t13.37289322\t20.99166378\t10.11831281\t27.04659437\r\n1.995502612\t1.995495354\t0.045349749\t0\t2.107084218\t0.95256744\t1.726805519\t84.95285272\t82.19469683\t83.15221287\t81.37275326\t81.40875472\t24.17121793\t14.18369356\t13.44938704\t13.33654253\t20.95588696\t10.10821786\t27.0257419\r\n3.485510848\t3.485879124\t2.12797696\t2.107084218\t0\t2.690817215\t3.335092424\t83.06183212\t80.30813598\t81.2738957\t79.47857211\t79.5149\t23.3078386\t12.37415418\t11.72088759\t11.48623566\t19.06975001\t8.0814959\t24.91872689\r\n1.043867842\t1.043840523\t0.907229104\t0.95256744\t2.690817215\t0\t0.776146592\t85.72532328\t82.96973548\t83.93198388\t82.14329292\t82.17948968\t25.12340423\t14.98902476\t14.28513822\t14.12265973\t21.72709198\t10.37975791\t27.49426357\r\n0.302111766\t0.301812113\t1.681552044\t1.726805519\t3.335092424\t0.776146592\t0\t86.39692438\t83.64318272\t84.6086705\t82.81365124\t82.8499822\t25.89393315\t15.69097514\t15.00598099\t14.81325771\t22.40402258\t10.72506046\t27.95475568\r\n86.53754762\t86.53795777\t84.98895345\t84.95285272\t83.06183212\t85.72532328\t86.39692438\t0\t2.784056299\t2.115378101\t3.592699243\t3.55447642\t67.45150094\t70.78812687\t71.60197135\t71.61685609\t63.99904083\t77.48346607\t61.64286707\r\n83.78510566\t83.78551307\t82.23092177\t82.19469683\t80.30813598\t82.96973548\t83.64318272\t2.784056299\t0\t1.196326277\t1.058218953\t1.012217459\t64.67828567\t68.02660818\t68.83652677\t68.85826762\t61.24275477\t74.76787565\t59.00989918\r\n84.75282145\t84.75322419\t83.18867303\t83.15221287\t81.2738957\t83.93198388\t84.6086705\t2.115378101\t1.196326277\t0\t2.254291389\t2.20828588\t65.45050761\t68.97840161\t69.77964632\t69.81586121\t62.20537972\t75.78431266\t60.09066956\r\n82.9534702\t82.95388198\t81.40875472\t81.37275326\t79.47857211\t82.14329292\t82.81365124\t3.592699243\t1.058218953\t2.254291389\t0\t0.046005686\t64.03108715\t67.21123856\t68.02924605\t68.03734456\t60.41790968\t73.89077428\t58.07210156\r\n82.98989215\t82.99030374\t81.44476589\t81.40875472\t79.5149\t82.17948968\t82.8499822\t3.55447642\t1.012217459\t2.20828588\t0.046005686\t0\t64.05947669\t67.24693201\t68.06459108\t68.07327999\t60.45399813\t73.92914571\t58.11306589\r\n26.16671135\t26.16670599\t24.21656659\t24.17121793\t23.3078386\t25.12340423\t25.89393315\t67.45150094\t64.67828567\t65.45050761\t64.03108715\t64.05947669\t0\t14.94634989\t14.47399026\t15.76107662\t15.13093723\t24.12471833\t26.88548218\r\n15.85736704\t15.85771634\t14.22106846\t14.18369356\t12.37415418\t14.98902476\t15.69097514\t70.78812687\t68.02660818\t68.97840161\t67.21123856\t67.24693201\t14.94634989\t0\t1.148233919\t1.001951244\t6.849226939\t9.626393279\t15.9811711\r\n15.18721355\t15.18752642\t13.48832542\t13.44938704\t11.72088759\t14.28513822\t15.00598099\t71.60197135\t68.83652677\t69.77964632\t68.02924605\t68.06459108\t14.47399026\t1.148233919\t0\t1.381147146\t7.786547077\t9.771067867\t17.1262391\r\n14.97174021\t14.97210747\t13.37289322\t13.33654253\t11.48623566\t14.12265973\t14.81325771\t71.61685609\t68.85826762\t69.81586121\t68.03734456\t68.07327999\t15.76107662\t1.001951244\t1.381147146\t0\t7.627064455\t8.658757412\t16.11638162\r\n22.55114901\t22.55154299\t20.99166378\t20.95588696\t19.06975001\t21.72709198\t22.40402258\t63.99904083\t61.24275477\t62.20537972\t60.41790968\t60.45399813\t15.13093723\t6.849226939\t7.786547077\t7.627064455\t0\t14.61255215\t11.85676168\r\n10.70767068\t10.70830547\t10.11831281\t10.10821786\t8.0814959\t10.37975791\t10.72506046\t77.48346607\t74.76787565\t75.78431266\t73.89077428\t73.92914571\t24.12471833\t9.626393279\t9.771067867\t8.658757412\t14.61255215\t0\t17.43086334\r\n27.98081693\t27.98140911\t27.04659437\t27.0257419\t24.91872689\t27.49426357\t27.95475568\t61.64286707\t59.00989918\t60.09066956\t58.07210156\t58.11306589\t26.88548218\t15.9811711\t17.1262391\t16.11638162\t11.85676168\t17.43086334\t0];\r\n\r\nassert(abs(sum(sum((procGPS(coords)-dist_correct))))\u003c0.005*max(max(dist_correct)))","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":379,"edited_by":223089,"edited_at":"2022-05-20T18:56:16.000Z","deleted_by":null,"deleted_at":null,"solvers_count":38,"test_suite_updated_at":"2022-05-20T18:56:16.000Z","rescore_all_solutions":false,"group_id":26,"created_at":"2014-08-09T13:16:53.000Z","updated_at":"2026-04-01T15:40:43.000Z","published_at":"2014-08-09T14:01:42.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA problem that arises when performing geographically weighted regression is determining the distance between GPS coordinates. GIS (geographical information system) data is usually reported as a function of latitude and longitude.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA common form of GIS data is a CSV file of latitude, longitude, z triples, where z is some quantity that varies with space.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs a prelude to interpolation, the distance between a given point and every other given point in an area needs to be calculated.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a set of GPS coordinates, return the distance (in miles) between each point and every point around it using the haversine formula (\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://en.wikipedia.org/wiki/Haversine_formula\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e ) and taking the radius of Earth to be 3959 miles.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee Test Suite for Examples\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":44882,"title":"Opposite point of the earth, what is the antipodal of a point ?","description":"Given two strings(lat and long) that represent the geographic coordinates of a point in the earth, you have to find out what is the opposite or most farthest point of the earth from that point(antipodal).  \r\n The strings will be 'r.dd C', where r is the real part, dd(the mantissa in decimal, not in minutes and dd can be present or not with the form dd,d or '\u003cnothing\u003e', equal the point(.)) and C the cardinal point (S,N,E or W). \r\nYou have to return two strings (lat and long) with the same format that the input.\r\n\r\n*Extra question:* What is the opposite point of north pole? And why is not possible to calculate it by this method ?\r\n\r\nSuppose the earth is spherical, not flat (Lol)","description_html":"\u003cp\u003eGiven two strings(lat and long) that represent the geographic coordinates of a point in the earth, you have to find out what is the opposite or most farthest point of the earth from that point(antipodal).  \r\n The strings will be 'r.dd C', where r is the real part, dd(the mantissa in decimal, not in minutes and dd can be present or not with the form dd,d or '\u0026lt;nothing\u0026gt;', equal the point(.)) and C the cardinal point (S,N,E or W). \r\nYou have to return two strings (lat and long) with the same format that the input.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExtra question:\u003c/b\u003e What is the opposite point of north pole? And why is not possible to calculate it by this method ?\u003c/p\u003e\u003cp\u003eSuppose the earth is spherical, not flat (Lol)\u003c/p\u003e","function_template":"function [lat_o,long_o] = opposite_earth_point(lat,long)\r\n  [lat_o long_o] = [lat long];\r\nend","test_suite":"%% \r\n%Mathworks headquarters\r\nlat = '42.3 N';\r\nlong = '71.37 W';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct = '42.3 S';\r\nlong_o_correct = '108.63 E';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))\r\n\r\n%% \r\n%San Antonio\r\nlat = '29.31 N';\r\nlong = '98.46 W';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct = '29.31 S';\r\nlong_o_correct= '81.54 E';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))\r\n\r\n%%\r\n%My city \r\nlat = '32.9 S';\r\nlong = '68.82 W';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct= '32.9 N';\r\nlong_o_correct = '111.18 E';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))\r\n\r\n%%\r\n%Big Ben \r\nlat = '51.5 N';\r\nlong = '0.12 W';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct= '51.5 S';\r\nlong_o_correct = '179.88 E';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))\r\n\r\n%%\r\n%Wellington\r\nlat = '41.27 S';\r\nlong = '174.78 E';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct= '41.27 N';\r\nlong_o_correct = '5.22 W';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))\r\n\r\n%%\r\n%Some point of Brasil\r\nlat = '1 S';\r\nlong = '50 W';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct= '1 N';\r\nlong_o_correct = '130 E';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))\r\n\r\n%%\r\n% Some point near to Moscú\r\nlat = '55 N';\r\nlong = '37 E';\r\n[lat_o long_o]=opposite_earth_point(lat,long);\r\nlat_o_correct= '55 S';\r\nlong_o_correct = '143 W';\r\nassert(isequal([lat_o long_o],[lat_o_correct long_o_correct]))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":289312,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":18,"test_suite_updated_at":"2019-04-18T18:26:43.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2019-04-18T18:22:19.000Z","updated_at":"2026-03-16T13:49:41.000Z","published_at":"2019-04-18T18:22:19.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven two strings(lat and long) that represent the geographic coordinates of a point in the earth, you have to find out what is the opposite or most farthest point of the earth from that point(antipodal). The strings will be 'r.dd C', where r is the real part, dd(the mantissa in decimal, not in minutes and dd can be present or not with the form dd,d or '\u0026lt;nothing\u0026gt;', equal the point(.)) and C the cardinal point (S,N,E or W). You have to return two strings (lat and long) with the same format that the input.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExtra question:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e What is the opposite point of north pole? And why is not possible to calculate it by this method ?\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSuppose the earth is spherical, not flat (Lol)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":2497,"title":"Distance between two GPS Coordinates","description":"A problem that arises when performing geographically weighted regression is determining the distance between GPS coordinates. GIS (geographical information system) data is usually reported as a function of latitude and longitude.\r\nA common form of GIS data is a CSV file of latitude, longitude, z triples, where z is some quantity that varies with space.\r\nAs a prelude to interpolation, the distance between a given point and every other given point in an area needs to be calculated.\r\nGiven a set of GPS coordinates, return the distance (in miles) between each point and every point around it using the haversine formula ( http://en.wikipedia.org/wiki/Haversine_formula ) and taking the radius of Earth to be 3959 miles.\r\nSee Test Suite for Examples","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 204px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 102px; transform-origin: 407px 102px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 368.5px 8px; transform-origin: 368.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA problem that arises when performing geographically weighted regression is determining the distance between GPS coordinates. GIS (geographical information system) data is usually reported as a function of latitude and longitude.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 373.5px 8px; transform-origin: 373.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA common form of GIS data is a CSV file of latitude, longitude, z triples, where z is some quantity that varies with space.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 366.5px 8px; transform-origin: 366.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAs a prelude to interpolation, the distance between a given point and every other given point in an area needs to be calculated.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 371px 8px; transform-origin: 371px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a set of GPS coordinates, return the distance (in miles) between each point and every point around it using the haversine formula (\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ehttp://en.wikipedia.org/wiki/Haversine_formula\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 156px 8px; transform-origin: 156px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e ) and taking the radius of Earth to be 3959 miles.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 88px 8px; transform-origin: 88px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSee Test Suite for Examples\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function dist = procGPS(coords)\r\n\r\nend","test_suite":"%%\r\ncoords = [\r\n47.7891\t-103.074\r\n47.7885\t-103.051\r\n47.7598\t-103.055\r\n47.76\t-103.055\r\n47.761\t-103.055];\r\ndist_correct = [\r\n   0.00000   1.06856   2.20846   2.19580   2.13270\r\n   1.06856   0.00000   1.99178   1.97802   1.90924\r\n   2.20846   1.99178   0.00000   0.01382   0.08292\r\n   2.19580   1.97802   0.01382   0.00000   0.06910\r\n   2.13270   1.90924   0.08292   0.06910   0.00000];\r\nassert(abs(sum(sum((procGPS(coords)-dist_correct))))\u003c0.005*max(max(dist_correct)))\r\n\r\n%%\r\ncoords = [\r\n48.9803\t-103.808\r\n48.98031 -103.808\r\n48.9806\t-103.765\r\n48.9806\t-103.764\r\n48.9534\t-103.743\r\n48.9809\t-103.785\r\n48.9822\t-103.802\r\n48.2269\t-102.295\r\n48.2559\t-102.337\r\n48.2556\t-102.311\r\n48.2557\t-102.36\r\n48.2557\t-102.359\r\n48.9818\t-103.231\r\n48.8639\t-103.507\r\n48.8804\t-103.51\r\n48.8648\t-103.529\r\n48.7935\t-103.401\r\n48.8379\t-103.715\r\n48.63282 -103.492268];\r\n\r\ndist_correct = [\r\n0\t0.000690976\t1.950155232\t1.995502612\t3.485510848\t1.043867842\t0.302111766\t86.53754762\t83.78510566\t84.75282145\t82.9534702\t82.98989215\t26.16671135\t15.85736704\t15.18721355\t14.97174021\t22.55114901\t10.70767068\t27.98081693\r\n0.000690976\t0\t1.950147814\t1.995495354\t3.485879124\t1.043840523\t0.301812113\t86.53795777\t83.78551307\t84.75322419\t82.95388198\t82.99030374\t26.16670599\t15.85771634\t15.18752642\t14.97210747\t22.55154299\t10.70830547\t27.98140911\r\n1.950155232\t1.950147814\t0\t0.045349749\t2.12797696\t0.907229104\t1.681552044\t84.98895345\t82.23092177\t83.18867303\t81.40875472\t81.44476589\t24.21656659\t14.22106846\t13.48832542\t13.37289322\t20.99166378\t10.11831281\t27.04659437\r\n1.995502612\t1.995495354\t0.045349749\t0\t2.107084218\t0.95256744\t1.726805519\t84.95285272\t82.19469683\t83.15221287\t81.37275326\t81.40875472\t24.17121793\t14.18369356\t13.44938704\t13.33654253\t20.95588696\t10.10821786\t27.0257419\r\n3.485510848\t3.485879124\t2.12797696\t2.107084218\t0\t2.690817215\t3.335092424\t83.06183212\t80.30813598\t81.2738957\t79.47857211\t79.5149\t23.3078386\t12.37415418\t11.72088759\t11.48623566\t19.06975001\t8.0814959\t24.91872689\r\n1.043867842\t1.043840523\t0.907229104\t0.95256744\t2.690817215\t0\t0.776146592\t85.72532328\t82.96973548\t83.93198388\t82.14329292\t82.17948968\t25.12340423\t14.98902476\t14.28513822\t14.12265973\t21.72709198\t10.37975791\t27.49426357\r\n0.302111766\t0.301812113\t1.681552044\t1.726805519\t3.335092424\t0.776146592\t0\t86.39692438\t83.64318272\t84.6086705\t82.81365124\t82.8499822\t25.89393315\t15.69097514\t15.00598099\t14.81325771\t22.40402258\t10.72506046\t27.95475568\r\n86.53754762\t86.53795777\t84.98895345\t84.95285272\t83.06183212\t85.72532328\t86.39692438\t0\t2.784056299\t2.115378101\t3.592699243\t3.55447642\t67.45150094\t70.78812687\t71.60197135\t71.61685609\t63.99904083\t77.48346607\t61.64286707\r\n83.78510566\t83.78551307\t82.23092177\t82.19469683\t80.30813598\t82.96973548\t83.64318272\t2.784056299\t0\t1.196326277\t1.058218953\t1.012217459\t64.67828567\t68.02660818\t68.83652677\t68.85826762\t61.24275477\t74.76787565\t59.00989918\r\n84.75282145\t84.75322419\t83.18867303\t83.15221287\t81.2738957\t83.93198388\t84.6086705\t2.115378101\t1.196326277\t0\t2.254291389\t2.20828588\t65.45050761\t68.97840161\t69.77964632\t69.81586121\t62.20537972\t75.78431266\t60.09066956\r\n82.9534702\t82.95388198\t81.40875472\t81.37275326\t79.47857211\t82.14329292\t82.81365124\t3.592699243\t1.058218953\t2.254291389\t0\t0.046005686\t64.03108715\t67.21123856\t68.02924605\t68.03734456\t60.41790968\t73.89077428\t58.07210156\r\n82.98989215\t82.99030374\t81.44476589\t81.40875472\t79.5149\t82.17948968\t82.8499822\t3.55447642\t1.012217459\t2.20828588\t0.046005686\t0\t64.05947669\t67.24693201\t68.06459108\t68.07327999\t60.45399813\t73.92914571\t58.11306589\r\n26.16671135\t26.16670599\t24.21656659\t24.17121793\t23.3078386\t25.12340423\t25.89393315\t67.45150094\t64.67828567\t65.45050761\t64.03108715\t64.05947669\t0\t14.94634989\t14.47399026\t15.76107662\t15.13093723\t24.12471833\t26.88548218\r\n15.85736704\t15.85771634\t14.22106846\t14.18369356\t12.37415418\t14.98902476\t15.69097514\t70.78812687\t68.02660818\t68.97840161\t67.21123856\t67.24693201\t14.94634989\t0\t1.148233919\t1.001951244\t6.849226939\t9.626393279\t15.9811711\r\n15.18721355\t15.18752642\t13.48832542\t13.44938704\t11.72088759\t14.28513822\t15.00598099\t71.60197135\t68.83652677\t69.77964632\t68.02924605\t68.06459108\t14.47399026\t1.148233919\t0\t1.381147146\t7.786547077\t9.771067867\t17.1262391\r\n14.97174021\t14.97210747\t13.37289322\t13.33654253\t11.48623566\t14.12265973\t14.81325771\t71.61685609\t68.85826762\t69.81586121\t68.03734456\t68.07327999\t15.76107662\t1.001951244\t1.381147146\t0\t7.627064455\t8.658757412\t16.11638162\r\n22.55114901\t22.55154299\t20.99166378\t20.95588696\t19.06975001\t21.72709198\t22.40402258\t63.99904083\t61.24275477\t62.20537972\t60.41790968\t60.45399813\t15.13093723\t6.849226939\t7.786547077\t7.627064455\t0\t14.61255215\t11.85676168\r\n10.70767068\t10.70830547\t10.11831281\t10.10821786\t8.0814959\t10.37975791\t10.72506046\t77.48346607\t74.76787565\t75.78431266\t73.89077428\t73.92914571\t24.12471833\t9.626393279\t9.771067867\t8.658757412\t14.61255215\t0\t17.43086334\r\n27.98081693\t27.98140911\t27.04659437\t27.0257419\t24.91872689\t27.49426357\t27.95475568\t61.64286707\t59.00989918\t60.09066956\t58.07210156\t58.11306589\t26.88548218\t15.9811711\t17.1262391\t16.11638162\t11.85676168\t17.43086334\t0];\r\n\r\nassert(abs(sum(sum((procGPS(coords)-dist_correct))))\u003c0.005*max(max(dist_correct)))","published":true,"deleted":false,"likes_count":2,"comments_count":4,"created_by":379,"edited_by":223089,"edited_at":"2022-05-20T18:56:16.000Z","deleted_by":null,"deleted_at":null,"solvers_count":38,"test_suite_updated_at":"2022-05-20T18:56:16.000Z","rescore_all_solutions":false,"group_id":26,"created_at":"2014-08-09T13:16:53.000Z","updated_at":"2026-04-01T15:40:43.000Z","published_at":"2014-08-09T14:01:42.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA problem that arises when performing geographically weighted regression is determining the distance between GPS coordinates. GIS (geographical information system) data is usually reported as a function of latitude and longitude.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA common form of GIS data is a CSV file of latitude, longitude, z triples, where z is some quantity that varies with space.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs a prelude to interpolation, the distance between a given point and every other given point in an area needs to be calculated.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a set of GPS coordinates, return the distance (in miles) between each point and every point around it using the haversine formula (\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttp://en.wikipedia.org/wiki/Haversine_formula\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e ) and taking the radius of Earth to be 3959 miles.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSee Test Suite for Examples\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"term":"tag:\"gps\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"gps\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"gps\"","","\"","gps","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f0f4c4d3d40\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f0f4c4d3ca0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f0f4c4d33e0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f0f4c4d3fc0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f0f4c4d3f20\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f0f4c4d3e80\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f0f4c4d3de0\u003e":"tag:\"gps\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f0f4c4d3de0\u003e":"tag:\"gps\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"gps\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"gps\"","","\"","gps","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f0f4c4d3d40\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f0f4c4d3ca0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f0f4c4d33e0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f0f4c4d3fc0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f0f4c4d3f20\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f0f4c4d3e80\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f0f4c4d3de0\u003e":"tag:\"gps\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f0f4c4d3de0\u003e":"tag:\"gps\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":44882,"difficulty_rating":"easy-medium"},{"id":2497,"difficulty_rating":"medium"}]}}