{"group":{"group":{"id":174,"name":"Basics - Rounding","lockable":false,"created_at":"2019-01-31T03:50:57.000Z","updated_at":"2026-04-06T14:01:22.000Z","description":"These problems will test the skills in rounding. ","is_default":false,"created_by":232412,"badge_id":62,"featured":false,"trending":false,"solution_count_in_trending_period":133,"trending_last_calculated":"2026-04-06T00:00:00.000Z","image_id":430,"published":true,"community_created":true,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"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\u003eThese problems will test the skills in rounding. \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\"}]}","description_html":"\u003cdiv style = \"text-align: start; line-height: normal; 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: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; perspective-origin: 289.5px 10.5px; transform-origin: 289.5px 10.5px; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; perspective-origin: 266.5px 10.5px; transform-origin: 266.5px 10.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThese problems will test the skills in rounding. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","published_at":"2019-05-08T20:18:26.000Z"},"current_player":null},"problems":[{"id":42641,"title":"MATLAB Basic: rounding ","description":"Do rounding near to zero \r\n\r\nExample: -8.8, answer -8\r\n\r\n+8.1  answer 8","description_html":"\u003cp\u003eDo rounding near to zero\u003c/p\u003e\u003cp\u003eExample: -8.8, answer -8\u003c/p\u003e\u003cp\u003e+8.1  answer 8\u003c/p\u003e","function_template":"function y = round_zero(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = -8.8;\r\ny_correct = -8;\r\nassert(isequal(round_zero(x),y_correct))\r\n\r\n%%\r\nx =  8.8;\r\ny_correct =  8;\r\nassert(isequal(round_zero(x),y_correct))\r\n\r\n%%\r\nx =  0.8;\r\ny_correct =  0;\r\nassert(isequal(round_zero(x),y_correct))\r\n\r\n%%\r\nx =  0.4;\r\ny_correct =  0;\r\nassert(isequal(round_zero(x),y_correct))\r\n\r\n\r\n%%\r\nx =  0;\r\ny_correct =  0;\r\nassert(isequal(round_zero(x),y_correct))\r\n\r\n%%\r\nx =  eps;\r\ny_correct =  0;\r\nassert(isequal(round_zero(x),y_correct))\r\n\r\n%%\r\nx =  pi;\r\ny_correct =  3;\r\nassert(isequal(round_zero(x),y_correct))","published":true,"deleted":false,"likes_count":50,"comments_count":10,"created_by":27760,"edited_by":427930,"edited_at":"2024-04-30T18:06:07.000Z","deleted_by":null,"deleted_at":null,"solvers_count":6338,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-10-01T05:13:22.000Z","updated_at":"2026-04-07T02:09:30.000Z","published_at":"2024-04-30T18:06:07.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eDo rounding near to zero\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\u003eExample: -8.8, answer -8\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\u003e+8.1 answer 8\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":42642,"title":"MATLAB Basic: rounding II","description":"Do rounding nearest integer.\r\n\r\nExample: -8.8, answer -9\r\n\r\n+8.1 answer 8\r\n\r\n+8.50 answer 9","description_html":"\u003cp\u003eDo rounding nearest integer.\u003c/p\u003e\u003cp\u003eExample: -8.8, answer -9\u003c/p\u003e\u003cp\u003e+8.1 answer 8\u003c/p\u003e\u003cp\u003e+8.50 answer 9\u003c/p\u003e","function_template":"function y = round_x(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = -8.8;\r\ny_correct = -9;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx = -8.4;\r\ny_correct = -8;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx =  8.8;\r\ny_correct =  9;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx =  8.4;\r\ny_correct =  8;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx =  8.49;\r\ny_correct =  8;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx =  128.52;\r\ny_correct =  129;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n\r\n%%\r\nx =  pi;\r\ny_correct =  3;\r\nassert(isequal(round_x(x),y_correct))","published":true,"deleted":false,"likes_count":21,"comments_count":4,"created_by":27760,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6300,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-10-01T05:25:01.000Z","updated_at":"2026-04-07T02:10:19.000Z","published_at":"2015-10-01T05:25:01.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eDo rounding nearest integer.\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\u003eExample: -8.8, answer -9\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\u003e+8.1 answer 8\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\u003e+8.50 answer 9\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":42643,"title":"MATLAB Basic: rounding III","description":"Do rounding towards minus infinity.\r\n\r\nExample: -8.8, answer -9\r\n\r\n+8.1 answer 8\r\n\r\n+8.50 answer 8","description_html":"\u003cp\u003eDo rounding towards minus infinity.\u003c/p\u003e\u003cp\u003eExample: -8.8, answer -9\u003c/p\u003e\u003cp\u003e+8.1 answer 8\u003c/p\u003e\u003cp\u003e+8.50 answer 8\u003c/p\u003e","function_template":"function y = round_x(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = -8.8;\r\ny_correct = -9;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx = -8.4;\r\ny_correct = -9;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx =  8.8;\r\ny_correct =  8;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx =  8.4;\r\ny_correct =  8;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx =  8.49;\r\ny_correct =  8;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx =  128.52;\r\ny_correct =  128;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n\r\n%%\r\nx =  pi;\r\ny_correct =  3;\r\nassert(isequal(round_x(x),y_correct))","published":true,"deleted":false,"likes_count":18,"comments_count":2,"created_by":27760,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6052,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-10-01T05:28:46.000Z","updated_at":"2026-04-07T02:11:04.000Z","published_at":"2015-10-01T05:28:46.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eDo rounding towards minus infinity.\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\u003eExample: -8.8, answer -9\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\u003e+8.1 answer 8\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\u003e+8.50 answer 8\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":42644,"title":"MATLAB Basic: rounding IV","description":"Do rounding towards plus infinity.\r\n\r\nExample: -8.8, answer -8\r\n\r\n+8.1 answer 9\r\n\r\n+8.50 answer 9","description_html":"\u003cp\u003eDo rounding towards plus infinity.\u003c/p\u003e\u003cp\u003eExample: -8.8, answer -8\u003c/p\u003e\u003cp\u003e+8.1 answer 9\u003c/p\u003e\u003cp\u003e+8.50 answer 9\u003c/p\u003e","function_template":"function y = round_x(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = -8.8;\r\ny_correct = -8;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx = -8.4;\r\ny_correct = -8;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx =  8.8;\r\ny_correct =  9;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx =  8.4;\r\ny_correct =  9;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx =  8.49;\r\ny_correct =  9;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n%%\r\nx =  128.52;\r\ny_correct =  129;\r\nassert(isequal(round_x(x),y_correct))\r\n\r\n\r\n%%\r\nx =  pi;\r\ny_correct =  4;\r\nassert(isequal(round_x(x),y_correct))","published":true,"deleted":false,"likes_count":21,"comments_count":2,"created_by":27760,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6044,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-10-01T05:31:31.000Z","updated_at":"2026-04-07T02:12:49.000Z","published_at":"2015-10-01T05:31:31.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eDo rounding towards plus infinity.\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\u003eExample: -8.8, answer -8\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\u003e+8.1 answer 9\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\u003e+8.50 answer 9\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":2559,"title":" Check that number is whole number ","description":"Check that number is whole number Say x=15, then answer is 1. x=15.2 , then answer is 0. http://en.wikipedia.org/wiki/Whole_number","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: 42px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 21px; transform-origin: 407px 21px; vertical-align: baseline; \"\u003e\u003cdiv style=\"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: 284px 8px; transform-origin: 284px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCheck that number is whole number Say x=15, then answer is 1. x=15.2 , then answer is 0.\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/Whole_number\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 15;\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 15.25;\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 10;\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = pi;\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = exp(3);\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 100;\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = [1 1.5 2];\r\ny_correct = [1 0 1];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":34,"comments_count":6,"created_by":27760,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":5223,"test_suite_updated_at":"2021-07-01T17:15:13.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-09-06T13:14:59.000Z","updated_at":"2026-04-07T02:49:23.000Z","published_at":"2014-09-06T13:16:20.000Z","restored_at":null,"restored_by":null,"spam":false,"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\u003eCheck that number is whole number Say x=15, then answer is 1. x=15.2 , then answer is 0.\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/Whole_number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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\"}]}"},{"id":2866,"title":"Matlab Basics - Rounding II","description":"Write a script to round a variable x to 3 decimal places:\r\n\r\ne.g. x = 2.3456 --\u003e y = 2.346","description_html":"\u003cp\u003eWrite a script to round a variable x to 3 decimal places:\u003c/p\u003e\u003cp\u003ee.g. x = 2.3456 --\u0026gt; y = 2.346\u003c/p\u003e","function_template":"function y = round_3_d_p(x)\r\n  y = ;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1.000;\r\nassert(isequal(round_3_d_p(x),y_correct))\r\n%%\r\nx = 2.3456;\r\ny_correct = 2.346;\r\nassert(isequal(round_3_d_p(x),y_correct))\r\n%%\r\nx = 16.2683254;\r\ny_correct = 16.268;\r\nassert(isequal(round_3_d_p(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":24,"comments_count":3,"created_by":34237,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":5639,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-01-21T17:15:01.000Z","updated_at":"2026-04-07T02:15:04.000Z","published_at":"2015-01-22T19:28:10.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eWrite a script to round a variable x to 3 decimal places:\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\u003ee.g. x = 2.3456 --\u0026gt; y = 2.346\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":2867,"title":"Matlab Basics - Rounding III","description":"Write a script to round a large number to the nearest 10,000\r\n\r\ne.g. x = 12,358,466,243 --\u003e y = 12,358,470,000","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: 51px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 25.5px; transform-origin: 407px 25.5px; vertical-align: baseline; \"\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: 190px 8px; transform-origin: 190px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a script to round a large number to the nearest 10,000\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: 149.5px 8px; transform-origin: 149.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ee.g. x = 12,358,466,243 --\u0026gt; y = 12,358,470,000\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = round_ten_thou(x)\r\n  y = ;\r\nend","test_suite":"%%\r\nx = 12358466243;\r\ny_correct = 12358470000;\r\nassert(isequal(round_ten_thou(x),y_correct))\r\n%%\r\nx = -1235846.325;\r\ny_correct = -1240000;\r\nassert(isequal(round_ten_thou(x),y_correct))\r\n%%\r\nx = 1266243.325;\r\ny_correct = 1270000;\r\nassert(isequal(round_ten_thou(x),y_correct))\r\n%%\r\nx = 987654321;\r\ny_correct = 987650000;\r\nassert(isequal(round_ten_thou(x),y_correct))\r\n%%\r\nx = [1:4999];\r\ny_correct = zeros(1,4999);\r\nassert(isequal(round_ten_thou(x),y_correct))\r\n%%\r\nx = [];\r\nassert(isempty(round_ten_thou(x)))\r\n%%\r\nx = [-5001:-1:-6000];\r\ny_correct = -1e4*ones(1,1e3);\r\nassert(isequal(round_ten_thou(x),y_correct))\r\n%%\r\nx = -54321.67890;\r\ny_correct = -5e4;\r\nassert(isequal(round_ten_thou(x),y_correct))","published":true,"deleted":false,"likes_count":29,"comments_count":7,"created_by":34237,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":5183,"test_suite_updated_at":"2021-05-09T15:34:34.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-01-21T17:19:47.000Z","updated_at":"2026-04-07T02:15:44.000Z","published_at":"2015-01-22T19:27:53.000Z","restored_at":null,"restored_by":null,"spam":false,"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\u003eWrite a script to round a large number to the nearest 10,000\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\u003ee.g. x = 12,358,466,243 --\u0026gt; y = 12,358,470,000\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\"}]}"},{"id":2120,"title":"Rounding off numbers to n decimals","description":"Inspired by a mistake in one of the problems I created, I created this problem where you have to round off a floating point number to n decimals. There are 2 inputs to the function: x: floating point number and n: number of decimals which need to match with the given solutions.","description_html":"\u003cp\u003eInspired by a mistake in one of the problems I created, I created this problem where you have to round off a floating point number to n decimals. There are 2 inputs to the function: x: floating point number and n: number of decimals which need to match with the given solutions.\u003c/p\u003e","function_template":"function y = myround(x,n)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\nn=1;\r\ny_correct = 1;\r\nassert(isequal(myround(x,n),y_correct))\r\n%%\r\nx = pi;\r\nn=5;\r\ny_correct = 3.14159;\r\nassert(isequal(myround(x,n),y_correct))\r\n%%\r\nx = 0.5*sqrt(2);\r\nn=6;\r\ny_correct = 0.707107;\r\nassert(isequal(myround(x,n),y_correct))\r\n%%\r\nx = exp(1);\r\nn=9;\r\ny_correct = 2.718281828;\r\nassert(isequal(myround(x,n),y_correct))\r\n%%\r\nx = 0.00123456;\r\nn=6;\r\ny_correct = 0.001235;\r\nassert(isequal(myround(x,n),y_correct))\r\n","published":true,"deleted":false,"likes_count":23,"comments_count":3,"created_by":20079,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":5535,"test_suite_updated_at":"2014-01-15T04:17:27.000Z","rescore_all_solutions":false,"group_id":38,"created_at":"2014-01-15T04:03:48.000Z","updated_at":"2026-04-07T02:16:22.000Z","published_at":"2014-01-15T04:14:20.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eInspired by a mistake in one of the problems I created, I created this problem where you have to round off a floating point number to n decimals. There are 2 inputs to the function: x: floating point number and n: number of decimals which need to match with the given solutions.\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":43278,"title":"Make roundn function","description":"Make roundn function using round.\r\n\r\n  x=0.55555\r\n  y=function(x,1)\r\n  y=1\r\n\r\n  y=function(x,2)\r\n  y=0.6\r\n\r\n  y=function(x,3)\r\n  y=0.56\r\n\r\n\r\n\r\n","description_html":"\u003cp\u003eMake roundn function using round.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ex=0.55555\r\ny=function(x,1)\r\ny=1\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003ey=function(x,2)\r\ny=0.6\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003ey=function(x,3)\r\ny=0.56\r\n\u003c/pre\u003e","function_template":"function y = myroundn(x,n)\r\n  y = \r\nend","test_suite":"%%\r\nx = 0.5555;\r\nn = 1;\r\ny_correct = 1;\r\nassert(isequal(myroundn(x,n),y_correct))\r\n\r\n%%\r\nx = 0.5555;\r\nn = 2;\r\ny_correct = 0.6;\r\nassert(isequal(myroundn(x,n),y_correct))\r\n\r\n%%\r\nx = 0.5555;\r\nn = 3;\r\ny_correct = 0.56;\r\nassert(isequal(myroundn(x,n),y_correct))\r\n\r\n%%\r\nx = 0.1111;\r\nn = 1;\r\ny_correct = 0;\r\nassert(isequal(myroundn(x,n),y_correct))\r\n\r\n%%\r\nx = 0.1111;\r\nn = 2;\r\ny_correct = 0.1;\r\nassert(isequal(myroundn(x,n),y_correct))\r\n\r\n%%\r\nx = 0.1111;\r\nn = 3;\r\ny_correct = 0.11;\r\nassert(isequal(myroundn(x,n),y_correct))\r\n\r\n%%\r\nx = 4.2736;\r\nn = 1;\r\ny_correct = 4;\r\nassert(isequal(myroundn(x,n),y_correct))\r\n\r\n%%\r\nx = 4.2736;\r\nn = 2;\r\ny_correct = 4.3;\r\nassert(isequal(myroundn(x,n),y_correct))\r\n\r\n%%\r\nx = 4.2736;\r\nn = 3;\r\ny_correct = 4.27;\r\nassert(isequal(myroundn(x,n),y_correct))\r\n\r\n%%\r\nx = 4.2736;\r\nn = 4;\r\ny_correct = 4.274;\r\nassert(isequal(myroundn(x,n),y_correct))","published":true,"deleted":false,"likes_count":30,"comments_count":3,"created_by":33533,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4521,"test_suite_updated_at":"2016-11-22T18:46:30.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-09T12:34:11.000Z","updated_at":"2026-04-07T15:14:41.000Z","published_at":"2016-10-09T12:34:11.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\u003eMake roundn function using round.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[x=0.55555\\ny=function(x,1)\\ny=1\\n\\ny=function(x,2)\\ny=0.6\\n\\ny=function(x,3)\\ny=0.56]]\u003e\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":713,"title":"Find the maximum number of decimal places in a set of numbers","description":"Given a vector or matrix of values, calculate the maximum number of decimal places within the input. Trailing zeros do not count as significant. No significant digits will result in an answer of 0.\r\nFor example:\r\nx = [0.01 0.888 1.0 40.151 39.1244];\r\n\r\ny = 4;\r\nThe maximum number of significant decimal places from the input is 4 (39.1244).","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: 174.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 87.15px; transform-origin: 407px 87.15px; 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: 382px 8px; transform-origin: 382px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a vector or matrix of values, calculate the maximum number of decimal places within the input. Trailing zeros do not count as significant. No significant digits will result in an answer of 0.\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: 41px 8px; transform-origin: 41px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor example:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 61.3px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 30.65px; transform-origin: 404px 30.65px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 144px 8.5px; tab-size: 4; transform-origin: 144px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ex = [0.01 0.888 1.0 40.151 39.1244];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 8.5px; tab-size: 4; transform-origin: 0px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; 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; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 24px 8.5px; tab-size: 4; transform-origin: 24px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003ey = 4;\u003c/span\u003e\u003c/span\u003e\u003c/div\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: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; 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: 253px 8px; transform-origin: 253px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe maximum number of significant decimal places from the input is 4 (39.1244).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = find_max_sigdec(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('find_max_sigdec.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp ') || ...\r\n          contains(filetext, 'elseif'); \r\nassert(~illegal)\r\n\r\n%%\r\nx = [1.000 1.04 0.22 10.1;\r\n  2.05 2.33 4.1 1000.31;\r\n  5.00010 6.429 7.492 8.0];\r\ny_correct = 4;\r\nassert(isequal(find_max_sigdec(x),y_correct))\r\n\r\n%%\r\nN = randi(6,1);\r\nx1 = rand(1,100);\r\nfor k = 1:100\r\n  x(1,k) = round(x1(1,k)*10^N)/10^N;\r\nend\r\nassert(isequal(find_max_sigdec(x), N))\r\n\r\n%%\r\nN = randi(6,1);\r\na = rand(5,20);\r\nfor k = 1:20\r\nfor m = 1:5\r\nx(m,k) = round(a(m,k)*10^N)/10^N;\r\nend\r\nend\r\nassert(isequal(find_max_sigdec(x), N))\r\n\r\n%%\r\nx = 1;\r\nassert(isequal(find_max_sigdec(x), 0))","published":true,"deleted":false,"likes_count":82,"comments_count":21,"created_by":726,"edited_by":223089,"edited_at":"2023-01-04T18:03:44.000Z","deleted_by":null,"deleted_at":null,"solvers_count":3393,"test_suite_updated_at":"2023-01-04T18:03:44.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-05-23T22:21:12.000Z","updated_at":"2026-04-07T15:16:32.000Z","published_at":"2012-05-23T22:34:43.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\u003eGiven a vector or matrix of values, calculate the maximum number of decimal places within the input. Trailing zeros do not count as significant. No significant digits will result in an answer of 0.\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\u003eFor example:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[x = [0.01 0.888 1.0 40.151 39.1244];\\n\\ny = 4;]]\u003e\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\u003eThe maximum number of significant decimal places from the input is 4 (39.1244).\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\"}]}"}],"no_progress_badge":{"id":53,"name":"Unknown","symbol":"unknown","description":"Partially completed groups","description_html":null,"image_location":"/images/responsive/supporting/matlabcentral/cody/badges/problem_groups_unknown_2.png","bonus":null,"players_count":0,"active":false,"created_by":null,"updated_by":null,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"created_at":"2018-01-10T23:20:29.000Z","updated_at":"2018-01-10T23:20:29.000Z","community_badge_id":null,"award_multiples":false}}