{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-05-26T00:16:20.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-05-26T00: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":44054,"title":"Write a function to calculate step size delta if bits per sample and input range is given for quantization.","description":"numBit = bits per sample; range = input max value - min value; delta = step size; l = number of levels;","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: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; 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 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: 316px 8px; transform-origin: 316px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003enumBit = bits per sample; range = input max value - min value; delta = step size; l = number of levels;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function delta = getdelta(numbBit,range)\r\n  l     = numBit;\r\n  delta = range;\r\nend","test_suite":"%%\r\nnumBit = 3;\r\nrange = 10;\r\ndelta = 1.25;\r\nassert(isequal(getdelta(numBit,range),delta))\r\n\r\n%%\r\nnumBit = 4;\r\nrange = 16;\r\ndelta = 1;\r\nassert(isequal(getdelta(numBit,range),delta))\r\n\r\n%%\r\nnumBit = 3;\r\nrange = 16;\r\ndelta = 2;\r\nassert(isequal(getdelta(numBit,range),delta))\r\n\r\n%%\r\nnumBit = randi(10);\r\nrange = 0;\r\ndelta = 0;\r\nassert(isequal(getdelta(numBit,range),delta))\r\n\r\n%%\r\nnumBit = 3;\r\nrange = 3;\r\ndelta = 0.375;\r\nassert(isequal(getdelta(numBit,range),delta))\r\n\r\n%%\r\nnumBit = 0;\r\nrange = randi(100);\r\ndelta = 1.25;\r\nassert(isequal(getdelta(numBit,range),range))\r\n\r\n%%\r\nnumBit = 10;\r\nrange = 1234;\r\ndelta = 1.2051;\r\nassert(isequal(round(getdelta(numBit,range),4),delta))","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":112010,"edited_by":223089,"edited_at":"2023-02-14T10:14:11.000Z","deleted_by":null,"deleted_at":null,"solvers_count":25,"test_suite_updated_at":"2023-02-14T10:14:13.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-01-25T23:42:31.000Z","updated_at":"2026-05-29T02:44:52.000Z","published_at":"2017-01-25T23:42:37.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\u003enumBit = bits per sample; range = input max value - min value; delta = step size; l = number of levels;\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":43821,"title":"write a function to calculate the snr after quantizing the signal in dB","description":"osig : original signal \r\n\r\nqsig : quantized signal \r\n\r\nqerror : quantization error \r\n\r\nHINT: snr = 10×log10(sum(osig × osig)/sum(qerror × qerror))  [dB]\r\n","description_html":"\u003cp\u003eosig : original signal\u003c/p\u003e\u003cp\u003eqsig : quantized signal\u003c/p\u003e\u003cp\u003eqerror : quantization error\u003c/p\u003e\u003cp\u003eHINT: snr = 10×log10(sum(osig × osig)/sum(qerror × qerror))  [dB]\u003c/p\u003e","function_template":"function snr= snrdB(osig,qerror)\r\n  snr =osig;\r\nend","test_suite":"%%\r\nosig = [100 200 300];\r\nqerror = [1 2 3];\r\ny =40;\r\nassert(isequal(snrdB(osig,qerror),y))","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":107355,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":52,"test_suite_updated_at":"2016-12-23T18:26:30.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-12-16T14:25:01.000Z","updated_at":"2026-05-29T02:43:35.000Z","published_at":"2016-12-23T18:26:30.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\u003eosig : original signal\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\u003eqsig : quantized signal\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\u003eqerror : quantization error\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\u003eHINT: snr = 10×log10(sum(osig × osig)/sum(qerror × qerror)) [dB]\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":43970,"title":"Calculate SNR in dB using original signal and quantized signal","description":"origs: the original signal\r\n\r\nquants: the quantized signal\r\n\r\n*hint* : need to calculate the quantization error and plug into SNR(dB) equation","description_html":"\u003cp\u003eorigs: the original signal\u003c/p\u003e\u003cp\u003equants: the quantized signal\u003c/p\u003e\u003cp\u003e\u003cb\u003ehint\u003c/b\u003e : need to calculate the quantization error and plug into SNR(dB) equation\u003c/p\u003e","function_template":"function SNR = calcSNRdB(origs,quants)\r\n  SNR = 0;\r\nend","test_suite":"%%\r\norigs = [100 200 300];\r\nquants = [99  198  297];\r\nSNR = 40;\r\nassert(isequal(calcSNRdB(origs,quants),SNR))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":108357,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":34,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-12-28T03:16:49.000Z","updated_at":"2026-05-29T02:43:38.000Z","published_at":"2016-12-28T03:18:57.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\u003eorigs: the original signal\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003equants: the quantized signal\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ehint\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e : need to calculate the quantization error and plug into SNR(dB) equation\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":43983,"title":"Find the quantization index of an analog value using a 6-bit quantizer.","description":"Given a sinusoidal waveform x(t)=4.5*sin(2*pi*100*t) is sampled at 8000 sample per second. Assume that signal range is between -5V to 5V. Find the coded integer index (quantization index) of an analog value using a 6-bit quantizer.","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: 380px 8px; transform-origin: 380px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a sinusoidal waveform x(t)=4.5*sin(2*pi*100*t) is sampled at 8000 sample per second. Assume that signal range is between -5V to 5V. Find the coded integer index (quantization index) of an analog value using a 6-bit quantizer.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = coded_int_index(x)\r\n    y = x;\r\nend","test_suite":"%%\r\nx = -5;\r\ny_correct = 0;\r\nassert(isequal(coded_int_index(x),y_correct))\r\n%%\r\nx = -3;\r\ny_correct = 13;\r\nassert(isequal(coded_int_index(x),y_correct))\r\n%%\r\nx = 0;\r\ny_correct = 32;\r\nassert(isequal(coded_int_index(x),y_correct))\r\n%%\r\nx = 1;\r\ny_correct = 38;\r\nassert(isequal(coded_int_index(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = 63;\r\nassert(isequal(coded_int_index(x),y_correct))\r\n%%\r\nx = randi([-5 0]);\r\ny_correct = 6*(x+5)+floor((x+5)/2);\r\nassert(isequal(coded_int_index(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":107779,"edited_by":223089,"edited_at":"2023-02-27T15:31:25.000Z","deleted_by":null,"deleted_at":null,"solvers_count":9,"test_suite_updated_at":"2023-02-27T15:31:25.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-12-29T17:59:07.000Z","updated_at":"2026-05-29T02:43:44.000Z","published_at":"2016-12-29T18:00:38.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 sinusoidal waveform x(t)=4.5*sin(2*pi*100*t) is sampled at 8000 sample per second. Assume that signal range is between -5V to 5V. Find the coded integer index (quantization index) of an analog value using a 6-bit quantizer.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"problem_search":{"problems":[{"id":44054,"title":"Write a function to calculate step size delta if bits per sample and input range is given for quantization.","description":"numBit = bits per sample; range = input max value - min value; delta = step size; l = number of levels;","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: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; 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 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: 316px 8px; transform-origin: 316px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003enumBit = bits per sample; range = input max value - min value; delta = step size; l = number of levels;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function delta = getdelta(numbBit,range)\r\n  l     = numBit;\r\n  delta = range;\r\nend","test_suite":"%%\r\nnumBit = 3;\r\nrange = 10;\r\ndelta = 1.25;\r\nassert(isequal(getdelta(numBit,range),delta))\r\n\r\n%%\r\nnumBit = 4;\r\nrange = 16;\r\ndelta = 1;\r\nassert(isequal(getdelta(numBit,range),delta))\r\n\r\n%%\r\nnumBit = 3;\r\nrange = 16;\r\ndelta = 2;\r\nassert(isequal(getdelta(numBit,range),delta))\r\n\r\n%%\r\nnumBit = randi(10);\r\nrange = 0;\r\ndelta = 0;\r\nassert(isequal(getdelta(numBit,range),delta))\r\n\r\n%%\r\nnumBit = 3;\r\nrange = 3;\r\ndelta = 0.375;\r\nassert(isequal(getdelta(numBit,range),delta))\r\n\r\n%%\r\nnumBit = 0;\r\nrange = randi(100);\r\ndelta = 1.25;\r\nassert(isequal(getdelta(numBit,range),range))\r\n\r\n%%\r\nnumBit = 10;\r\nrange = 1234;\r\ndelta = 1.2051;\r\nassert(isequal(round(getdelta(numBit,range),4),delta))","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":112010,"edited_by":223089,"edited_at":"2023-02-14T10:14:11.000Z","deleted_by":null,"deleted_at":null,"solvers_count":25,"test_suite_updated_at":"2023-02-14T10:14:13.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-01-25T23:42:31.000Z","updated_at":"2026-05-29T02:44:52.000Z","published_at":"2017-01-25T23:42:37.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\u003enumBit = bits per sample; range = input max value - min value; delta = step size; l = number of levels;\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":43821,"title":"write a function to calculate the snr after quantizing the signal in dB","description":"osig : original signal \r\n\r\nqsig : quantized signal \r\n\r\nqerror : quantization error \r\n\r\nHINT: snr = 10×log10(sum(osig × osig)/sum(qerror × qerror))  [dB]\r\n","description_html":"\u003cp\u003eosig : original signal\u003c/p\u003e\u003cp\u003eqsig : quantized signal\u003c/p\u003e\u003cp\u003eqerror : quantization error\u003c/p\u003e\u003cp\u003eHINT: snr = 10×log10(sum(osig × osig)/sum(qerror × qerror))  [dB]\u003c/p\u003e","function_template":"function snr= snrdB(osig,qerror)\r\n  snr =osig;\r\nend","test_suite":"%%\r\nosig = [100 200 300];\r\nqerror = [1 2 3];\r\ny =40;\r\nassert(isequal(snrdB(osig,qerror),y))","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":107355,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":52,"test_suite_updated_at":"2016-12-23T18:26:30.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-12-16T14:25:01.000Z","updated_at":"2026-05-29T02:43:35.000Z","published_at":"2016-12-23T18:26:30.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\u003eosig : original signal\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\u003eqsig : quantized signal\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\u003eqerror : quantization error\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\u003eHINT: snr = 10×log10(sum(osig × osig)/sum(qerror × qerror)) [dB]\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":43970,"title":"Calculate SNR in dB using original signal and quantized signal","description":"origs: the original signal\r\n\r\nquants: the quantized signal\r\n\r\n*hint* : need to calculate the quantization error and plug into SNR(dB) equation","description_html":"\u003cp\u003eorigs: the original signal\u003c/p\u003e\u003cp\u003equants: the quantized signal\u003c/p\u003e\u003cp\u003e\u003cb\u003ehint\u003c/b\u003e : need to calculate the quantization error and plug into SNR(dB) equation\u003c/p\u003e","function_template":"function SNR = calcSNRdB(origs,quants)\r\n  SNR = 0;\r\nend","test_suite":"%%\r\norigs = [100 200 300];\r\nquants = [99  198  297];\r\nSNR = 40;\r\nassert(isequal(calcSNRdB(origs,quants),SNR))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":108357,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":34,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-12-28T03:16:49.000Z","updated_at":"2026-05-29T02:43:38.000Z","published_at":"2016-12-28T03:18:57.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\u003eorigs: the original signal\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003equants: the quantized signal\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ehint\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e : need to calculate the quantization error and plug into SNR(dB) equation\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":43983,"title":"Find the quantization index of an analog value using a 6-bit quantizer.","description":"Given a sinusoidal waveform x(t)=4.5*sin(2*pi*100*t) is sampled at 8000 sample per second. Assume that signal range is between -5V to 5V. Find the coded integer index (quantization index) of an analog value using a 6-bit quantizer.","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: 380px 8px; transform-origin: 380px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a sinusoidal waveform x(t)=4.5*sin(2*pi*100*t) is sampled at 8000 sample per second. Assume that signal range is between -5V to 5V. Find the coded integer index (quantization index) of an analog value using a 6-bit quantizer.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = coded_int_index(x)\r\n    y = x;\r\nend","test_suite":"%%\r\nx = -5;\r\ny_correct = 0;\r\nassert(isequal(coded_int_index(x),y_correct))\r\n%%\r\nx = -3;\r\ny_correct = 13;\r\nassert(isequal(coded_int_index(x),y_correct))\r\n%%\r\nx = 0;\r\ny_correct = 32;\r\nassert(isequal(coded_int_index(x),y_correct))\r\n%%\r\nx = 1;\r\ny_correct = 38;\r\nassert(isequal(coded_int_index(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = 63;\r\nassert(isequal(coded_int_index(x),y_correct))\r\n%%\r\nx = randi([-5 0]);\r\ny_correct = 6*(x+5)+floor((x+5)/2);\r\nassert(isequal(coded_int_index(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":107779,"edited_by":223089,"edited_at":"2023-02-27T15:31:25.000Z","deleted_by":null,"deleted_at":null,"solvers_count":9,"test_suite_updated_at":"2023-02-27T15:31:25.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-12-29T17:59:07.000Z","updated_at":"2026-05-29T02:43:44.000Z","published_at":"2016-12-29T18:00:38.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 sinusoidal waveform x(t)=4.5*sin(2*pi*100*t) is sampled at 8000 sample per second. Assume that signal range is between -5V to 5V. Find the coded integer index (quantization index) of an analog value using a 6-bit quantizer.\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\"}]}"}],"errors":[],"facets":[[],[{"value":"easy","count":3,"selected":false},{"value":"medium","count":1,"selected":false}]],"term":"tag:\"quantization\"","page":1,"per_page":50,"sort":"map(difficulty_value,0,0,999) asc"}}