{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.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":"2025-12-14T00: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":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":5531,"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-02T02:10:16.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":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":5635,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-01-21T17:15:01.000Z","updated_at":"2026-04-01T21:36:22.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":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":6333,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-10-01T05:13:22.000Z","updated_at":"2026-04-03T17:40:53.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":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":5179,"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-01T21:37:46.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":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":5218,"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-02T02:09:33.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":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":4518,"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-02T02:10:47.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\"}]}"}],"problem_search":{"errors":[],"problems":[{"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":5531,"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-02T02:10:16.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":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":5635,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-01-21T17:15:01.000Z","updated_at":"2026-04-01T21:36:22.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":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":6333,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-10-01T05:13:22.000Z","updated_at":"2026-04-03T17:40:53.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":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":5179,"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-01T21:37:46.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":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":5218,"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-02T02:09:33.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":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":4518,"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-02T02:10:47.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\"}]}"}],"term":"group:\"Basics - Rounding\" difficulty_rating_bin:medium","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":"group:\"Basics - Rounding\" difficulty_rating_bin:medium","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"group":[["group:\"Basics - Rounding\"","","\"","Basics - Rounding","\""]],"difficulty_rating_bin":[["difficulty_rating_bin:medium","","","medium",""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f25247c24f0\u003e":["Basics - Rounding"],"#\u003cMathWorks::Search::Field:0x00007f25247c2450\u003e":["medium"]},"filters":{"#\u003cMathWorks::Search::Field:0x00007f25247c1550\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f25247c2770\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f25247c26d0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f25247c2630\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f25247c2590\u003e":"group:\"Basics - Rounding\" difficulty_rating_bin:medium"},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f25247c2590\u003e":"group:\"Basics - Rounding\" difficulty_rating_bin:medium"},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007f25247c24f0\u003e":["Basics - Rounding"],"#\u003cMathWorks::Search::Field:0x00007f25247c2450\u003e":["medium"]}},"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":"search","password":"J3bGPZzQ7asjJcCk","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":"group:\"Basics - Rounding\" difficulty_rating_bin:medium","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"group":[["group:\"Basics - Rounding\"","","\"","Basics - Rounding","\""]],"difficulty_rating_bin":[["difficulty_rating_bin:medium","","","medium",""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f25247c24f0\u003e":["Basics - Rounding"],"#\u003cMathWorks::Search::Field:0x00007f25247c2450\u003e":["medium"]},"filters":{"#\u003cMathWorks::Search::Field:0x00007f25247c1550\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f25247c2770\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f25247c26d0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f25247c2630\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f25247c2590\u003e":"group:\"Basics - Rounding\" difficulty_rating_bin:medium"},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f25247c2590\u003e":"group:\"Basics - Rounding\" difficulty_rating_bin:medium"},"queried_facets":{"#\u003cMathWorks::Search::Field:0x00007f25247c24f0\u003e":["Basics - Rounding"],"#\u003cMathWorks::Search::Field:0x00007f25247c2450\u003e":["medium"]}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":2120,"difficulty_rating":"easy-medium"},{"id":2866,"difficulty_rating":"easy-medium"},{"id":42641,"difficulty_rating":"easy-medium"},{"id":2867,"difficulty_rating":"easy-medium"},{"id":2559,"difficulty_rating":"easy-medium"},{"id":43278,"difficulty_rating":"easy-medium"}]}}