{"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":8045,"title":"Gold Standard","description":"Gold has long been used as currency and a standard for currency, due to its inherent value and rarity. Historical data for gold is available at \u003chttp://measuringworth.com/gold/ Measuring Worth\u003e.\r\n\r\nFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV) from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard can be accurately used to convert between years. Round the result to two decimal places. If HY is outside of the historical-data range, return NaN.\r\n\r\nAs an example, with HY = 2000 and HV = 1000:\r\n\r\n* GV(HY=2000) = $280.10\r\n* N = 1000/280.10 = 3.57 (ounces of gold)\r\n* CV = 3.57*1270 (current $/ounce of gold) = $4534.09.\r\n","description_html":"\u003cp\u003eGold has long been used as currency and a standard for currency, due to its inherent value and rarity. Historical data for gold is available at \u003ca href = \"http://measuringworth.com/gold/\"\u003eMeasuring Worth\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV) from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard can be accurately used to convert between years. Round the result to two decimal places. If HY is outside of the historical-data range, return NaN.\u003c/p\u003e\u003cp\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/p\u003e\u003cul\u003e\u003cli\u003eGV(HY=2000) = $280.10\u003c/li\u003e\u003cli\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/li\u003e\u003cli\u003eCV = 3.57*1270 (current $/ounce of gold) = $4534.09.\u003c/li\u003e\u003c/ul\u003e","function_template":"function [CV] = gold_standard(HY,HV)\r\n\r\nY = 1791:2014;\r\nGV = [19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 20.1, 21.64, 20.95, 19.46, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.94, 20.69, 20.69, 21.64, 20.86, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.7, 20.67, 20.67, 20.67, 20.67, 23.42, 30.02, 42.03, 32.52, 29.13, 28.57, 28.88, 27.49, 23.75, 23.09, 23.24, 23.52, 22.99, 23.75, 23.05, 21.66, 20.84, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 24.44, 34.94, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39.26, 41.51, 36.41, 41.25, 58.6, 97.81, 159.74, 161.49, 125.32, 148.31, 193.55, 307.5, 612.56, 459.64, 375.91, 424, 360.66, 317.66, 368.24, 447.95, 438.31, 382.58, 384.93, 363.29, 344.97, 360.91, 385.42, 385.5, 389.09, 332.39, 295.24, 279.91, 280.1, 272.22, 311.33, 364.8, 410.52, 446, 606, 699, 874, 975, 1227, 1572, 1700, 1415, 1270];\r\n\r\nCV = 1;\r\n\r\nend\r\n","test_suite":"%% current check\r\nHY = 2014; HV = 1270; CV_corr = 1270;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%% out-of-range check 1\r\nHY = 500; HV = 50; CV_corr = NaN;\r\nassert(isnan(gold_standard(HY,HV)))\r\n\r\n%% out-of-range check 2\r\nHY = 2500; HV = 5000; CV_corr = NaN;\r\nassert(isnan(gold_standard(HY,HV)))\r\n\r\n%%\r\nHY = 2010; HV = 1000; CV_corr = 1035.04;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2005; HV = 1000; CV_corr = 2847.53;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2000; HV = 1000; CV_corr = 4534.09;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1995; HV = 1000; CV_corr = 3294.42;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1990; HV = 1000; CV_corr = 3299.3;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1950; HV = 1000; CV_corr = 36285.71;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1900; HV = 1000; CV_corr = 61441.7;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1850; HV = 1000; CV_corr = 61441.7;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1800; HV = 1000; CV_corr = 65497.68;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":63,"test_suite_updated_at":"2015-03-30T16:49:21.000Z","rescore_all_solutions":false,"group_id":30,"created_at":"2015-03-30T15:58:58.000Z","updated_at":"2026-03-24T03:34:47.000Z","published_at":"2015-03-30T15:58:58.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\u003eGold has long been used as currency and a standard for currency, due to its inherent value and rarity. Historical data for gold is available at\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=\\\"http://measuringworth.com/gold/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMeasuring Worth\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV) from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard can be accurately used to convert between years. Round the result to two decimal places. If HY is outside of the historical-data range, return NaN.\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\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGV(HY=2000) = $280.10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCV = 3.57*1270 (current $/ounce of gold) = $4534.09.\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":8046,"title":"Gold/Silver Standard","description":"Pursuant to the \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard Gold Standard\u003e problem, suppose that you have data for silver rather than gold to make an assessment regarding historical currency values. Historical data for the silver-to-gold ratio is also available from \u003chttp://measuringworth.com/gold/ Measuring Worth\u003e.\r\n\r\nFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV), in addition to the silver-to-gold ratio, from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard must be converted to the silver standard to accurately convert between years. Round the result to two decimal places. If HY is outside of the historical data range, return NaN.\r\n\r\nAs an example, with HY = 2000 and HV = 1000:\r\n\r\n* GV(HY=2000) = $280.10\r\n* N = 1000/280.10 = 3.57 (ounces of gold)\r\n* SR(HY=2000) = 55.96\r\n* NS = 55.96*3.57 = 199.79 (ounces of silver)\r\n* NG = 199.79/66.38 = 3.01 (current ounces of gold) [SR(2014) = 66.38]\r\n* CV = 3.01*1270 (current $/ounce of gold) = $3822.36.","description_html":"\u003cp\u003ePursuant to the \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\"\u003eGold Standard\u003c/a\u003e problem, suppose that you have data for silver rather than gold to make an assessment regarding historical currency values. Historical data for the silver-to-gold ratio is also available from \u003ca href = \"http://measuringworth.com/gold/\"\u003eMeasuring Worth\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV), in addition to the silver-to-gold ratio, from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard must be converted to the silver standard to accurately convert between years. Round the result to two decimal places. If HY is outside of the historical data range, return NaN.\u003c/p\u003e\u003cp\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/p\u003e\u003cul\u003e\u003cli\u003eGV(HY=2000) = $280.10\u003c/li\u003e\u003cli\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/li\u003e\u003cli\u003eSR(HY=2000) = 55.96\u003c/li\u003e\u003cli\u003eNS = 55.96*3.57 = 199.79 (ounces of silver)\u003c/li\u003e\u003cli\u003eNG = 199.79/66.38 = 3.01 (current ounces of gold) [SR(2014) = 66.38]\u003c/li\u003e\u003cli\u003eCV = 3.01*1270 (current $/ounce of gold) = $3822.36.\u003c/li\u003e\u003c/ul\u003e","function_template":"function [CV] = gold_silver_standard(HY,HV)\r\n\r\nY = 1791:2014;\r\nGV = [19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 20.1, 21.64, 20.95, 19.46, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.94, 20.69, 20.69, 21.64, 20.86, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.7, 20.67, 20.67, 20.67, 20.67, 23.42, 30.02, 42.03, 32.52, 29.13, 28.57, 28.88, 27.49, 23.75, 23.09, 23.24, 23.52, 22.99, 23.75, 23.05, 21.66, 20.84, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 24.44, 34.94, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39.26, 41.51, 36.41, 41.25, 58.6, 97.81, 159.74, 161.49, 125.32, 148.31, 193.55, 307.5, 612.56, 459.64, 375.91, 424, 360.66, 317.66, 368.24, 447.95, 438.31, 382.58, 384.93, 363.29, 344.97, 360.91, 385.42, 385.5, 389.09, 332.39, 295.24, 279.91, 280.1, 272.22, 311.33, 364.8, 410.52, 446, 606, 699, 874, 975, 1227, 1572, 1700, 1415, 1270];\r\nSR = [15.05, 15.17, 15, 15.37, 15.55, 15.65, 15.41, 15.59, 15.74, 15.68, 15.46, 15.26, 15.41, 15.41, 15.79, 15.52, 15.43, 16.08, 15.96, 15.77, 15.53, 16.11, 16.25, 15.04, 15.26, 15.28, 15.11, 15.35, 15.33, 15.62, 15.95, 15.8, 15.84, 15.82, 15.7, 15.76, 15.74, 15.78, 15.78, 15.82, 15.72, 15.73, 15.93, 15.73, 15.8, 15.72, 15.83, 15.85, 15.62, 15.62, 15.7, 15.87, 15.93, 15.85, 15.92, 15.9, 15.8, 15.85, 15.78, 15.7, 15.46, 15.59, 15.33, 15.33, 15.38, 15.38, 15.27, 15.38, 15.19, 15.29, 15.5, 15.35, 15.37, 15.37, 15.44, 15.43, 15.57, 15.59, 15.6, 15.57, 15.57, 15.63, 15.93, 16.16, 16.64, 17.75, 17.2, 17.92, 18.39, 18.05, 18.25, 18.2, 18.64, 18.61, 19.41, 20.78, 21.1, 22, 22.1, 19.75, 20.92, 23.72, 26.49, 32.56, 31.6, 30.59, 34.2, 35.03, 34.36, 33.33, 34.68, 39.15, 38.1, 35.7, 33.87, 30.54, 31.24, 38.64, 39.74, 38.22, 38.33, 33.62, 34.19, 37.37, 40.48, 30.78, 24.61, 21, 18.44, 20.28, 32.76, 30.43, 31.69, 30.8, 29.78, 33.11, 36.47, 35.34, 38.78, 53.74, 71.25, 73.29, 69.83, 72.36, 54.19, 77.09, 77.44, 80.39, 88.84, 99.76, 99.73, 90.57, 77.67, 77.67, 67.4, 43.67, 48.73, 47.07, 48.61, 47.14, 39.12, 41.16, 41.04, 41.01, 39.24, 38.5, 38.5, 39.27, 38.34, 38.27, 37.82, 32.22, 27.34, 27.04, 27.04, 27.04, 22.56, 18.29, 23.16, 20.54, 26.66, 34.75, 38.21, 33.9, 36.51, 28.76, 32.05, 35.8, 27.69, 29.66, 43.65, 47.24, 37.03, 44.26, 51.68, 67.25, 63.84, 66.95, 69.49, 79.78, 89.83, 87.47, 83.85, 72.79, 74.78, 74.89, 67.91, 53.24, 53.26, 55.96, 61.95, 67.32, 74.22, 61.3, 60.7, 52.2, 51.91, 58.17, 66.27, 60.64, 44.75, 53.58, 59.31, 66.38];\r\n\r\nCV = 1;\r\n\r\nend\r\n","test_suite":"%% current check\r\nHY = 2014; HV = 1270; CV_corr = 1270;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%% out-of-range check 1\r\nHY = 500; HV = 50; CV_corr = NaN;\r\nassert(isnan(gold_silver_standard(HY,HV)))\r\n\r\n%% out-of-range check 2\r\nHY = 2500; HV = 5000; CV_corr = NaN;\r\nassert(isnan(gold_silver_standard(HY,HV)))\r\n\r\n%%\r\nHY = 2010; HV = 1000; CV_corr = 945.54;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2005; HV = 1000; CV_corr = 2603.88;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2000; HV = 1000; CV_corr = 3822.36;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1995; HV = 1000; CV_corr = 3711.31;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1990; HV = 1000; CV_corr = 3965.32;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1950; HV = 1000; CV_corr = 25768.43;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1900; HV = 1000; CV_corr = 30850.44;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1850; HV = 1000; CV_corr = 14532.01;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1800; HV = 1000; CV_corr = 15471.58;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tHY = 2000; HV = 1000; CV_corr = 3822.36;\r\n\tcase 2\r\n\t\tHY = 1995; HV = 1000; CV_corr = 3711.31;\r\n\tcase 3\r\n\t\tHY = 2005; HV = 1000; CV_corr = 2603.88;\r\n\tcase 4\r\n\t\tHY = 1800; HV = 1000; CV_corr = 15471.58;\r\nend\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tHY = 1995; HV = 1000; CV_corr = 3711.31;\r\n\tcase 2\r\n\t\tHY = 1990; HV = 1000; CV_corr = 3965.32;\r\n\tcase 3\r\n\t\tHY = 2010; HV = 1000; CV_corr = 945.54;\r\n\tcase 4\r\n\t\tHY = 1900; HV = 1000; CV_corr = 30850.44;\r\nend\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tHY = 1990; HV = 1000; CV_corr = 3965.32;\r\n\tcase 2\r\n\t\tHY = 1950; HV = 1000; CV_corr = 25768.43;\r\n\tcase 3\r\n\t\tHY = 1900; HV = 1000; CV_corr = 30850.44;\r\n\tcase 4\r\n\t\tHY = 2000; HV = 1000; CV_corr = 3822.36;\r\nend\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":56,"test_suite_updated_at":"2015-03-30T16:51:28.000Z","rescore_all_solutions":false,"group_id":30,"created_at":"2015-03-30T16:22:04.000Z","updated_at":"2026-03-27T06:19:08.000Z","published_at":"2015-03-30T16:22:04.000Z","restored_at":"2017-07-28T15:24:51.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"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\u003ePursuant to the\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=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGold Standard\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e problem, suppose that you have data for silver rather than gold to make an assessment regarding historical currency values. Historical data for the silver-to-gold ratio is also available from\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=\\\"http://measuringworth.com/gold/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMeasuring Worth\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV), in addition to the silver-to-gold ratio, from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard must be converted to the silver standard to accurately convert between years. Round the result to two decimal places. If HY is outside of the historical data range, return NaN.\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\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGV(HY=2000) = $280.10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSR(HY=2000) = 55.96\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNS = 55.96*3.57 = 199.79 (ounces of silver)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNG = 199.79/66.38 = 3.01 (current ounces of gold) [SR(2014) = 66.38]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCV = 3.01*1270 (current $/ounce of gold) = $3822.36.\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":8047,"title":"Weighted Gold/Silver Standard","description":"Building off of the \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard Gold Standard\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8046-gold-silver-standard Gold/Silver Standard\u003e problems, let's make a weighted currency convertor. The same data for gold value and silver-to-gold ratio will be provided in the function template.\r\n\r\nFor this problem, based on a historical year (HY) and a historical value (HV) in dollars, calculate the current value using the gold (CVG) and silver (CVS) references; see the referenced problems for details and examples of those individual problems. In this case, you will be provided a weighting that will range from 0 to 1, where 0 indicates complete weighting by gold and 1 indicates complete weighting by silver. Remember to round the result to two decimal places. If HY is outside of the historical data range, return NaN.\r\n\r\nAs an example, with HY = 2000, HV = 1000, and wt = 0.4:\r\n\r\n* CVG = $4534.09 (gold standard)\r\n* CVS = $3822.36 (silver standard)\r\n* CV = (1-0.4)*4534.09 + 0.4*3822.36 = $4249.40.","description_html":"\u003cp\u003eBuilding off of the \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\"\u003eGold Standard\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8046-gold-silver-standard\"\u003eGold/Silver Standard\u003c/a\u003e problems, let's make a weighted currency convertor. The same data for gold value and silver-to-gold ratio will be provided in the function template.\u003c/p\u003e\u003cp\u003eFor this problem, based on a historical year (HY) and a historical value (HV) in dollars, calculate the current value using the gold (CVG) and silver (CVS) references; see the referenced problems for details and examples of those individual problems. In this case, you will be provided a weighting that will range from 0 to 1, where 0 indicates complete weighting by gold and 1 indicates complete weighting by silver. Remember to round the result to two decimal places. If HY is outside of the historical data range, return NaN.\u003c/p\u003e\u003cp\u003eAs an example, with HY = 2000, HV = 1000, and wt = 0.4:\u003c/p\u003e\u003cul\u003e\u003cli\u003eCVG = $4534.09 (gold standard)\u003c/li\u003e\u003cli\u003eCVS = $3822.36 (silver standard)\u003c/li\u003e\u003cli\u003eCV = (1-0.4)*4534.09 + 0.4*3822.36 = $4249.40.\u003c/li\u003e\u003c/ul\u003e","function_template":"function [CV] = gold_silver_weighted_standard(HY,HV,wt)\r\n\r\nY = 1791:2014;\r\nGV = [19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 20.1, 21.64, 20.95, 19.46, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.94, 20.69, 20.69, 21.64, 20.86, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.7, 20.67, 20.67, 20.67, 20.67, 23.42, 30.02, 42.03, 32.52, 29.13, 28.57, 28.88, 27.49, 23.75, 23.09, 23.24, 23.52, 22.99, 23.75, 23.05, 21.66, 20.84, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 24.44, 34.94, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39.26, 41.51, 36.41, 41.25, 58.6, 97.81, 159.74, 161.49, 125.32, 148.31, 193.55, 307.5, 612.56, 459.64, 375.91, 424, 360.66, 317.66, 368.24, 447.95, 438.31, 382.58, 384.93, 363.29, 344.97, 360.91, 385.42, 385.5, 389.09, 332.39, 295.24, 279.91, 280.1, 272.22, 311.33, 364.8, 410.52, 446, 606, 699, 874, 975, 1227, 1572, 1700, 1415, 1270];\r\nSR = [15.05, 15.17, 15, 15.37, 15.55, 15.65, 15.41, 15.59, 15.74, 15.68, 15.46, 15.26, 15.41, 15.41, 15.79, 15.52, 15.43, 16.08, 15.96, 15.77, 15.53, 16.11, 16.25, 15.04, 15.26, 15.28, 15.11, 15.35, 15.33, 15.62, 15.95, 15.8, 15.84, 15.82, 15.7, 15.76, 15.74, 15.78, 15.78, 15.82, 15.72, 15.73, 15.93, 15.73, 15.8, 15.72, 15.83, 15.85, 15.62, 15.62, 15.7, 15.87, 15.93, 15.85, 15.92, 15.9, 15.8, 15.85, 15.78, 15.7, 15.46, 15.59, 15.33, 15.33, 15.38, 15.38, 15.27, 15.38, 15.19, 15.29, 15.5, 15.35, 15.37, 15.37, 15.44, 15.43, 15.57, 15.59, 15.6, 15.57, 15.57, 15.63, 15.93, 16.16, 16.64, 17.75, 17.2, 17.92, 18.39, 18.05, 18.25, 18.2, 18.64, 18.61, 19.41, 20.78, 21.1, 22, 22.1, 19.75, 20.92, 23.72, 26.49, 32.56, 31.6, 30.59, 34.2, 35.03, 34.36, 33.33, 34.68, 39.15, 38.1, 35.7, 33.87, 30.54, 31.24, 38.64, 39.74, 38.22, 38.33, 33.62, 34.19, 37.37, 40.48, 30.78, 24.61, 21, 18.44, 20.28, 32.76, 30.43, 31.69, 30.8, 29.78, 33.11, 36.47, 35.34, 38.78, 53.74, 71.25, 73.29, 69.83, 72.36, 54.19, 77.09, 77.44, 80.39, 88.84, 99.76, 99.73, 90.57, 77.67, 77.67, 67.4, 43.67, 48.73, 47.07, 48.61, 47.14, 39.12, 41.16, 41.04, 41.01, 39.24, 38.5, 38.5, 39.27, 38.34, 38.27, 37.82, 32.22, 27.34, 27.04, 27.04, 27.04, 22.56, 18.29, 23.16, 20.54, 26.66, 34.75, 38.21, 33.9, 36.51, 28.76, 32.05, 35.8, 27.69, 29.66, 43.65, 47.24, 37.03, 44.26, 51.68, 67.25, 63.84, 66.95, 69.49, 79.78, 89.83, 87.47, 83.85, 72.79, 74.78, 74.89, 67.91, 53.24, 53.26, 55.96, 61.95, 67.32, 74.22, 61.3, 60.7, 52.2, 51.91, 58.17, 66.27, 60.64, 44.75, 53.58, 59.31, 66.38];\r\n\r\nCV = 1;\r\n\r\nend\r\n","test_suite":"%% current check\r\nHY = 2014; HV = 1270; wt = 0.5; CV_corr = 1270;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%% out-of-range check 1\r\nHY = 500; HV = 50; wt = 0.5; CV_corr = NaN;\r\nassert(isnan(gold_silver_weighted_standard(HY,HV,wt)))\r\n\r\n%% out-of-range check 2\r\nHY = 2500; HV = 5000; wt = 0.5; CV_corr = NaN;\r\nassert(isnan(gold_silver_weighted_standard(HY,HV,wt)))\r\n\r\n%%\r\nHY = 2010; HV = 1000; wt = 0.5; CV_corr = 990.29;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 2005; HV = 1000; wt = 0.5; CV_corr = 2725.7;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 2000; HV = 1000; wt = 0.5; CV_corr = 4178.23;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1995; HV = 1000; wt = 0.5; CV_corr = 3502.87;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1990; HV = 1000; wt = 0.5; CV_corr = 3632.31;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1950; HV = 1000; wt = 0.5; CV_corr = 31027.07;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1900; HV = 1000; wt = 0.5; CV_corr = 46146.07;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1850; HV = 1000; wt = 0.5; CV_corr = 37986.86;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1800; HV = 1000; wt = 0.5; CV_corr = 40484.63;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 2000; HV = 1000;\r\nwt = randi(10)/10;\r\nswitch (wt*10)\r\n\tcase 0\r\n\t\tCV_corr = 4534.09;\r\n\tcase 1\r\n\t\tCV_corr = 4462.92;\r\n\tcase 2\r\n\t\tCV_corr = 4391.75;\r\n\tcase 3\r\n\t\tCV_corr = 4320.57;\r\n\tcase 4\r\n\t\tCV_corr = 4249.4;\r\n\tcase 5\r\n\t\tCV_corr = 4178.23;\r\n\tcase 6\r\n\t\tCV_corr = 4107.05;\r\n\tcase 7\r\n\t\tCV_corr = 4035.88;\r\n\tcase 8\r\n\t\tCV_corr = 3964.7;\r\n\tcase 9\r\n\t\tCV_corr = 3893.53;\r\n\tcase 10\r\n\t\tCV_corr = 3822.36;\r\nend\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1800; HV = 1000;\r\nwt = randi(10)/10;\r\nswitch (wt*10)\r\n\tcase 0\r\n\t\tCV_corr = 65497.68;\r\n\tcase 1\r\n\t\tCV_corr = 60495.07;\r\n\tcase 2\r\n\t\tCV_corr = 55492.46;\r\n\tcase 3\r\n\t\tCV_corr = 50489.85;\r\n\tcase 4\r\n\t\tCV_corr = 45487.24;\r\n\tcase 5\r\n\t\tCV_corr = 40484.63;\r\n\tcase 6\r\n\t\tCV_corr = 35482.02;\r\n\tcase 7\r\n\t\tCV_corr = 30479.41;\r\n\tcase 8\r\n\t\tCV_corr = 25476.8;\r\n\tcase 9\r\n\t\tCV_corr = 20474.19;\r\n\tcase 10\r\n\t\tCV_corr = 15471.58;\r\nend\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":50,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":30,"created_at":"2015-03-30T16:47:31.000Z","updated_at":"2026-03-27T06:22:48.000Z","published_at":"2015-03-30T16:47: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\",\"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\u003eBuilding off of the\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=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGold Standard\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\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=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8046-gold-silver-standard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGold/Silver Standard\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e problems, let's make a weighted currency convertor. The same data for gold value and silver-to-gold ratio will be provided in the function template.\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\u003eFor this problem, based on a historical year (HY) and a historical value (HV) in dollars, calculate the current value using the gold (CVG) and silver (CVS) references; see the referenced problems for details and examples of those individual problems. In this case, you will be provided a weighting that will range from 0 to 1, where 0 indicates complete weighting by gold and 1 indicates complete weighting by silver. Remember to round the result to two decimal places. If HY is outside of the historical data range, return NaN.\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\u003eAs an example, with HY = 2000, HV = 1000, and wt = 0.4:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCVG = $4534.09 (gold standard)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCVS = $3822.36 (silver standard)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCV = (1-0.4)*4534.09 + 0.4*3822.36 = $4249.40.\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":8045,"title":"Gold Standard","description":"Gold has long been used as currency and a standard for currency, due to its inherent value and rarity. Historical data for gold is available at \u003chttp://measuringworth.com/gold/ Measuring Worth\u003e.\r\n\r\nFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV) from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard can be accurately used to convert between years. Round the result to two decimal places. If HY is outside of the historical-data range, return NaN.\r\n\r\nAs an example, with HY = 2000 and HV = 1000:\r\n\r\n* GV(HY=2000) = $280.10\r\n* N = 1000/280.10 = 3.57 (ounces of gold)\r\n* CV = 3.57*1270 (current $/ounce of gold) = $4534.09.\r\n","description_html":"\u003cp\u003eGold has long been used as currency and a standard for currency, due to its inherent value and rarity. Historical data for gold is available at \u003ca href = \"http://measuringworth.com/gold/\"\u003eMeasuring Worth\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV) from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard can be accurately used to convert between years. Round the result to two decimal places. If HY is outside of the historical-data range, return NaN.\u003c/p\u003e\u003cp\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/p\u003e\u003cul\u003e\u003cli\u003eGV(HY=2000) = $280.10\u003c/li\u003e\u003cli\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/li\u003e\u003cli\u003eCV = 3.57*1270 (current $/ounce of gold) = $4534.09.\u003c/li\u003e\u003c/ul\u003e","function_template":"function [CV] = gold_standard(HY,HV)\r\n\r\nY = 1791:2014;\r\nGV = [19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 20.1, 21.64, 20.95, 19.46, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.94, 20.69, 20.69, 21.64, 20.86, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.7, 20.67, 20.67, 20.67, 20.67, 23.42, 30.02, 42.03, 32.52, 29.13, 28.57, 28.88, 27.49, 23.75, 23.09, 23.24, 23.52, 22.99, 23.75, 23.05, 21.66, 20.84, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 24.44, 34.94, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39.26, 41.51, 36.41, 41.25, 58.6, 97.81, 159.74, 161.49, 125.32, 148.31, 193.55, 307.5, 612.56, 459.64, 375.91, 424, 360.66, 317.66, 368.24, 447.95, 438.31, 382.58, 384.93, 363.29, 344.97, 360.91, 385.42, 385.5, 389.09, 332.39, 295.24, 279.91, 280.1, 272.22, 311.33, 364.8, 410.52, 446, 606, 699, 874, 975, 1227, 1572, 1700, 1415, 1270];\r\n\r\nCV = 1;\r\n\r\nend\r\n","test_suite":"%% current check\r\nHY = 2014; HV = 1270; CV_corr = 1270;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%% out-of-range check 1\r\nHY = 500; HV = 50; CV_corr = NaN;\r\nassert(isnan(gold_standard(HY,HV)))\r\n\r\n%% out-of-range check 2\r\nHY = 2500; HV = 5000; CV_corr = NaN;\r\nassert(isnan(gold_standard(HY,HV)))\r\n\r\n%%\r\nHY = 2010; HV = 1000; CV_corr = 1035.04;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2005; HV = 1000; CV_corr = 2847.53;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2000; HV = 1000; CV_corr = 4534.09;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1995; HV = 1000; CV_corr = 3294.42;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1990; HV = 1000; CV_corr = 3299.3;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1950; HV = 1000; CV_corr = 36285.71;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1900; HV = 1000; CV_corr = 61441.7;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1850; HV = 1000; CV_corr = 61441.7;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1800; HV = 1000; CV_corr = 65497.68;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":63,"test_suite_updated_at":"2015-03-30T16:49:21.000Z","rescore_all_solutions":false,"group_id":30,"created_at":"2015-03-30T15:58:58.000Z","updated_at":"2026-03-24T03:34:47.000Z","published_at":"2015-03-30T15:58:58.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\u003eGold has long been used as currency and a standard for currency, due to its inherent value and rarity. Historical data for gold is available at\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=\\\"http://measuringworth.com/gold/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMeasuring Worth\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV) from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard can be accurately used to convert between years. Round the result to two decimal places. If HY is outside of the historical-data range, return NaN.\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\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGV(HY=2000) = $280.10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCV = 3.57*1270 (current $/ounce of gold) = $4534.09.\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":8046,"title":"Gold/Silver Standard","description":"Pursuant to the \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard Gold Standard\u003e problem, suppose that you have data for silver rather than gold to make an assessment regarding historical currency values. Historical data for the silver-to-gold ratio is also available from \u003chttp://measuringworth.com/gold/ Measuring Worth\u003e.\r\n\r\nFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV), in addition to the silver-to-gold ratio, from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard must be converted to the silver standard to accurately convert between years. Round the result to two decimal places. If HY is outside of the historical data range, return NaN.\r\n\r\nAs an example, with HY = 2000 and HV = 1000:\r\n\r\n* GV(HY=2000) = $280.10\r\n* N = 1000/280.10 = 3.57 (ounces of gold)\r\n* SR(HY=2000) = 55.96\r\n* NS = 55.96*3.57 = 199.79 (ounces of silver)\r\n* NG = 199.79/66.38 = 3.01 (current ounces of gold) [SR(2014) = 66.38]\r\n* CV = 3.01*1270 (current $/ounce of gold) = $3822.36.","description_html":"\u003cp\u003ePursuant to the \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\"\u003eGold Standard\u003c/a\u003e problem, suppose that you have data for silver rather than gold to make an assessment regarding historical currency values. Historical data for the silver-to-gold ratio is also available from \u003ca href = \"http://measuringworth.com/gold/\"\u003eMeasuring Worth\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV), in addition to the silver-to-gold ratio, from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard must be converted to the silver standard to accurately convert between years. Round the result to two decimal places. If HY is outside of the historical data range, return NaN.\u003c/p\u003e\u003cp\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/p\u003e\u003cul\u003e\u003cli\u003eGV(HY=2000) = $280.10\u003c/li\u003e\u003cli\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/li\u003e\u003cli\u003eSR(HY=2000) = 55.96\u003c/li\u003e\u003cli\u003eNS = 55.96*3.57 = 199.79 (ounces of silver)\u003c/li\u003e\u003cli\u003eNG = 199.79/66.38 = 3.01 (current ounces of gold) [SR(2014) = 66.38]\u003c/li\u003e\u003cli\u003eCV = 3.01*1270 (current $/ounce of gold) = $3822.36.\u003c/li\u003e\u003c/ul\u003e","function_template":"function [CV] = gold_silver_standard(HY,HV)\r\n\r\nY = 1791:2014;\r\nGV = [19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 20.1, 21.64, 20.95, 19.46, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.94, 20.69, 20.69, 21.64, 20.86, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.7, 20.67, 20.67, 20.67, 20.67, 23.42, 30.02, 42.03, 32.52, 29.13, 28.57, 28.88, 27.49, 23.75, 23.09, 23.24, 23.52, 22.99, 23.75, 23.05, 21.66, 20.84, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 24.44, 34.94, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39.26, 41.51, 36.41, 41.25, 58.6, 97.81, 159.74, 161.49, 125.32, 148.31, 193.55, 307.5, 612.56, 459.64, 375.91, 424, 360.66, 317.66, 368.24, 447.95, 438.31, 382.58, 384.93, 363.29, 344.97, 360.91, 385.42, 385.5, 389.09, 332.39, 295.24, 279.91, 280.1, 272.22, 311.33, 364.8, 410.52, 446, 606, 699, 874, 975, 1227, 1572, 1700, 1415, 1270];\r\nSR = [15.05, 15.17, 15, 15.37, 15.55, 15.65, 15.41, 15.59, 15.74, 15.68, 15.46, 15.26, 15.41, 15.41, 15.79, 15.52, 15.43, 16.08, 15.96, 15.77, 15.53, 16.11, 16.25, 15.04, 15.26, 15.28, 15.11, 15.35, 15.33, 15.62, 15.95, 15.8, 15.84, 15.82, 15.7, 15.76, 15.74, 15.78, 15.78, 15.82, 15.72, 15.73, 15.93, 15.73, 15.8, 15.72, 15.83, 15.85, 15.62, 15.62, 15.7, 15.87, 15.93, 15.85, 15.92, 15.9, 15.8, 15.85, 15.78, 15.7, 15.46, 15.59, 15.33, 15.33, 15.38, 15.38, 15.27, 15.38, 15.19, 15.29, 15.5, 15.35, 15.37, 15.37, 15.44, 15.43, 15.57, 15.59, 15.6, 15.57, 15.57, 15.63, 15.93, 16.16, 16.64, 17.75, 17.2, 17.92, 18.39, 18.05, 18.25, 18.2, 18.64, 18.61, 19.41, 20.78, 21.1, 22, 22.1, 19.75, 20.92, 23.72, 26.49, 32.56, 31.6, 30.59, 34.2, 35.03, 34.36, 33.33, 34.68, 39.15, 38.1, 35.7, 33.87, 30.54, 31.24, 38.64, 39.74, 38.22, 38.33, 33.62, 34.19, 37.37, 40.48, 30.78, 24.61, 21, 18.44, 20.28, 32.76, 30.43, 31.69, 30.8, 29.78, 33.11, 36.47, 35.34, 38.78, 53.74, 71.25, 73.29, 69.83, 72.36, 54.19, 77.09, 77.44, 80.39, 88.84, 99.76, 99.73, 90.57, 77.67, 77.67, 67.4, 43.67, 48.73, 47.07, 48.61, 47.14, 39.12, 41.16, 41.04, 41.01, 39.24, 38.5, 38.5, 39.27, 38.34, 38.27, 37.82, 32.22, 27.34, 27.04, 27.04, 27.04, 22.56, 18.29, 23.16, 20.54, 26.66, 34.75, 38.21, 33.9, 36.51, 28.76, 32.05, 35.8, 27.69, 29.66, 43.65, 47.24, 37.03, 44.26, 51.68, 67.25, 63.84, 66.95, 69.49, 79.78, 89.83, 87.47, 83.85, 72.79, 74.78, 74.89, 67.91, 53.24, 53.26, 55.96, 61.95, 67.32, 74.22, 61.3, 60.7, 52.2, 51.91, 58.17, 66.27, 60.64, 44.75, 53.58, 59.31, 66.38];\r\n\r\nCV = 1;\r\n\r\nend\r\n","test_suite":"%% current check\r\nHY = 2014; HV = 1270; CV_corr = 1270;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%% out-of-range check 1\r\nHY = 500; HV = 50; CV_corr = NaN;\r\nassert(isnan(gold_silver_standard(HY,HV)))\r\n\r\n%% out-of-range check 2\r\nHY = 2500; HV = 5000; CV_corr = NaN;\r\nassert(isnan(gold_silver_standard(HY,HV)))\r\n\r\n%%\r\nHY = 2010; HV = 1000; CV_corr = 945.54;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2005; HV = 1000; CV_corr = 2603.88;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2000; HV = 1000; CV_corr = 3822.36;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1995; HV = 1000; CV_corr = 3711.31;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1990; HV = 1000; CV_corr = 3965.32;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1950; HV = 1000; CV_corr = 25768.43;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1900; HV = 1000; CV_corr = 30850.44;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1850; HV = 1000; CV_corr = 14532.01;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1800; HV = 1000; CV_corr = 15471.58;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tHY = 2000; HV = 1000; CV_corr = 3822.36;\r\n\tcase 2\r\n\t\tHY = 1995; HV = 1000; CV_corr = 3711.31;\r\n\tcase 3\r\n\t\tHY = 2005; HV = 1000; CV_corr = 2603.88;\r\n\tcase 4\r\n\t\tHY = 1800; HV = 1000; CV_corr = 15471.58;\r\nend\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tHY = 1995; HV = 1000; CV_corr = 3711.31;\r\n\tcase 2\r\n\t\tHY = 1990; HV = 1000; CV_corr = 3965.32;\r\n\tcase 3\r\n\t\tHY = 2010; HV = 1000; CV_corr = 945.54;\r\n\tcase 4\r\n\t\tHY = 1900; HV = 1000; CV_corr = 30850.44;\r\nend\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tHY = 1990; HV = 1000; CV_corr = 3965.32;\r\n\tcase 2\r\n\t\tHY = 1950; HV = 1000; CV_corr = 25768.43;\r\n\tcase 3\r\n\t\tHY = 1900; HV = 1000; CV_corr = 30850.44;\r\n\tcase 4\r\n\t\tHY = 2000; HV = 1000; CV_corr = 3822.36;\r\nend\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":56,"test_suite_updated_at":"2015-03-30T16:51:28.000Z","rescore_all_solutions":false,"group_id":30,"created_at":"2015-03-30T16:22:04.000Z","updated_at":"2026-03-27T06:19:08.000Z","published_at":"2015-03-30T16:22:04.000Z","restored_at":"2017-07-28T15:24:51.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"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\u003ePursuant to the\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=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGold Standard\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e problem, suppose that you have data for silver rather than gold to make an assessment regarding historical currency values. Historical data for the silver-to-gold ratio is also available from\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=\\\"http://measuringworth.com/gold/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMeasuring Worth\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV), in addition to the silver-to-gold ratio, from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard must be converted to the silver standard to accurately convert between years. Round the result to two decimal places. If HY is outside of the historical data range, return NaN.\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\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGV(HY=2000) = $280.10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSR(HY=2000) = 55.96\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNS = 55.96*3.57 = 199.79 (ounces of silver)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNG = 199.79/66.38 = 3.01 (current ounces of gold) [SR(2014) = 66.38]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCV = 3.01*1270 (current $/ounce of gold) = $3822.36.\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":8047,"title":"Weighted Gold/Silver Standard","description":"Building off of the \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard Gold Standard\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8046-gold-silver-standard Gold/Silver Standard\u003e problems, let's make a weighted currency convertor. The same data for gold value and silver-to-gold ratio will be provided in the function template.\r\n\r\nFor this problem, based on a historical year (HY) and a historical value (HV) in dollars, calculate the current value using the gold (CVG) and silver (CVS) references; see the referenced problems for details and examples of those individual problems. In this case, you will be provided a weighting that will range from 0 to 1, where 0 indicates complete weighting by gold and 1 indicates complete weighting by silver. Remember to round the result to two decimal places. If HY is outside of the historical data range, return NaN.\r\n\r\nAs an example, with HY = 2000, HV = 1000, and wt = 0.4:\r\n\r\n* CVG = $4534.09 (gold standard)\r\n* CVS = $3822.36 (silver standard)\r\n* CV = (1-0.4)*4534.09 + 0.4*3822.36 = $4249.40.","description_html":"\u003cp\u003eBuilding off of the \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\"\u003eGold Standard\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8046-gold-silver-standard\"\u003eGold/Silver Standard\u003c/a\u003e problems, let's make a weighted currency convertor. The same data for gold value and silver-to-gold ratio will be provided in the function template.\u003c/p\u003e\u003cp\u003eFor this problem, based on a historical year (HY) and a historical value (HV) in dollars, calculate the current value using the gold (CVG) and silver (CVS) references; see the referenced problems for details and examples of those individual problems. In this case, you will be provided a weighting that will range from 0 to 1, where 0 indicates complete weighting by gold and 1 indicates complete weighting by silver. Remember to round the result to two decimal places. If HY is outside of the historical data range, return NaN.\u003c/p\u003e\u003cp\u003eAs an example, with HY = 2000, HV = 1000, and wt = 0.4:\u003c/p\u003e\u003cul\u003e\u003cli\u003eCVG = $4534.09 (gold standard)\u003c/li\u003e\u003cli\u003eCVS = $3822.36 (silver standard)\u003c/li\u003e\u003cli\u003eCV = (1-0.4)*4534.09 + 0.4*3822.36 = $4249.40.\u003c/li\u003e\u003c/ul\u003e","function_template":"function [CV] = gold_silver_weighted_standard(HY,HV,wt)\r\n\r\nY = 1791:2014;\r\nGV = [19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 20.1, 21.64, 20.95, 19.46, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.94, 20.69, 20.69, 21.64, 20.86, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.7, 20.67, 20.67, 20.67, 20.67, 23.42, 30.02, 42.03, 32.52, 29.13, 28.57, 28.88, 27.49, 23.75, 23.09, 23.24, 23.52, 22.99, 23.75, 23.05, 21.66, 20.84, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 24.44, 34.94, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39.26, 41.51, 36.41, 41.25, 58.6, 97.81, 159.74, 161.49, 125.32, 148.31, 193.55, 307.5, 612.56, 459.64, 375.91, 424, 360.66, 317.66, 368.24, 447.95, 438.31, 382.58, 384.93, 363.29, 344.97, 360.91, 385.42, 385.5, 389.09, 332.39, 295.24, 279.91, 280.1, 272.22, 311.33, 364.8, 410.52, 446, 606, 699, 874, 975, 1227, 1572, 1700, 1415, 1270];\r\nSR = [15.05, 15.17, 15, 15.37, 15.55, 15.65, 15.41, 15.59, 15.74, 15.68, 15.46, 15.26, 15.41, 15.41, 15.79, 15.52, 15.43, 16.08, 15.96, 15.77, 15.53, 16.11, 16.25, 15.04, 15.26, 15.28, 15.11, 15.35, 15.33, 15.62, 15.95, 15.8, 15.84, 15.82, 15.7, 15.76, 15.74, 15.78, 15.78, 15.82, 15.72, 15.73, 15.93, 15.73, 15.8, 15.72, 15.83, 15.85, 15.62, 15.62, 15.7, 15.87, 15.93, 15.85, 15.92, 15.9, 15.8, 15.85, 15.78, 15.7, 15.46, 15.59, 15.33, 15.33, 15.38, 15.38, 15.27, 15.38, 15.19, 15.29, 15.5, 15.35, 15.37, 15.37, 15.44, 15.43, 15.57, 15.59, 15.6, 15.57, 15.57, 15.63, 15.93, 16.16, 16.64, 17.75, 17.2, 17.92, 18.39, 18.05, 18.25, 18.2, 18.64, 18.61, 19.41, 20.78, 21.1, 22, 22.1, 19.75, 20.92, 23.72, 26.49, 32.56, 31.6, 30.59, 34.2, 35.03, 34.36, 33.33, 34.68, 39.15, 38.1, 35.7, 33.87, 30.54, 31.24, 38.64, 39.74, 38.22, 38.33, 33.62, 34.19, 37.37, 40.48, 30.78, 24.61, 21, 18.44, 20.28, 32.76, 30.43, 31.69, 30.8, 29.78, 33.11, 36.47, 35.34, 38.78, 53.74, 71.25, 73.29, 69.83, 72.36, 54.19, 77.09, 77.44, 80.39, 88.84, 99.76, 99.73, 90.57, 77.67, 77.67, 67.4, 43.67, 48.73, 47.07, 48.61, 47.14, 39.12, 41.16, 41.04, 41.01, 39.24, 38.5, 38.5, 39.27, 38.34, 38.27, 37.82, 32.22, 27.34, 27.04, 27.04, 27.04, 22.56, 18.29, 23.16, 20.54, 26.66, 34.75, 38.21, 33.9, 36.51, 28.76, 32.05, 35.8, 27.69, 29.66, 43.65, 47.24, 37.03, 44.26, 51.68, 67.25, 63.84, 66.95, 69.49, 79.78, 89.83, 87.47, 83.85, 72.79, 74.78, 74.89, 67.91, 53.24, 53.26, 55.96, 61.95, 67.32, 74.22, 61.3, 60.7, 52.2, 51.91, 58.17, 66.27, 60.64, 44.75, 53.58, 59.31, 66.38];\r\n\r\nCV = 1;\r\n\r\nend\r\n","test_suite":"%% current check\r\nHY = 2014; HV = 1270; wt = 0.5; CV_corr = 1270;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%% out-of-range check 1\r\nHY = 500; HV = 50; wt = 0.5; CV_corr = NaN;\r\nassert(isnan(gold_silver_weighted_standard(HY,HV,wt)))\r\n\r\n%% out-of-range check 2\r\nHY = 2500; HV = 5000; wt = 0.5; CV_corr = NaN;\r\nassert(isnan(gold_silver_weighted_standard(HY,HV,wt)))\r\n\r\n%%\r\nHY = 2010; HV = 1000; wt = 0.5; CV_corr = 990.29;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 2005; HV = 1000; wt = 0.5; CV_corr = 2725.7;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 2000; HV = 1000; wt = 0.5; CV_corr = 4178.23;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1995; HV = 1000; wt = 0.5; CV_corr = 3502.87;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1990; HV = 1000; wt = 0.5; CV_corr = 3632.31;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1950; HV = 1000; wt = 0.5; CV_corr = 31027.07;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1900; HV = 1000; wt = 0.5; CV_corr = 46146.07;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1850; HV = 1000; wt = 0.5; CV_corr = 37986.86;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1800; HV = 1000; wt = 0.5; CV_corr = 40484.63;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 2000; HV = 1000;\r\nwt = randi(10)/10;\r\nswitch (wt*10)\r\n\tcase 0\r\n\t\tCV_corr = 4534.09;\r\n\tcase 1\r\n\t\tCV_corr = 4462.92;\r\n\tcase 2\r\n\t\tCV_corr = 4391.75;\r\n\tcase 3\r\n\t\tCV_corr = 4320.57;\r\n\tcase 4\r\n\t\tCV_corr = 4249.4;\r\n\tcase 5\r\n\t\tCV_corr = 4178.23;\r\n\tcase 6\r\n\t\tCV_corr = 4107.05;\r\n\tcase 7\r\n\t\tCV_corr = 4035.88;\r\n\tcase 8\r\n\t\tCV_corr = 3964.7;\r\n\tcase 9\r\n\t\tCV_corr = 3893.53;\r\n\tcase 10\r\n\t\tCV_corr = 3822.36;\r\nend\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1800; HV = 1000;\r\nwt = randi(10)/10;\r\nswitch (wt*10)\r\n\tcase 0\r\n\t\tCV_corr = 65497.68;\r\n\tcase 1\r\n\t\tCV_corr = 60495.07;\r\n\tcase 2\r\n\t\tCV_corr = 55492.46;\r\n\tcase 3\r\n\t\tCV_corr = 50489.85;\r\n\tcase 4\r\n\t\tCV_corr = 45487.24;\r\n\tcase 5\r\n\t\tCV_corr = 40484.63;\r\n\tcase 6\r\n\t\tCV_corr = 35482.02;\r\n\tcase 7\r\n\t\tCV_corr = 30479.41;\r\n\tcase 8\r\n\t\tCV_corr = 25476.8;\r\n\tcase 9\r\n\t\tCV_corr = 20474.19;\r\n\tcase 10\r\n\t\tCV_corr = 15471.58;\r\nend\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":50,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":30,"created_at":"2015-03-30T16:47:31.000Z","updated_at":"2026-03-27T06:22:48.000Z","published_at":"2015-03-30T16:47: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\",\"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\u003eBuilding off of the\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=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGold Standard\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\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=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8046-gold-silver-standard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGold/Silver Standard\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e problems, let's make a weighted currency convertor. The same data for gold value and silver-to-gold ratio will be provided in the function template.\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\u003eFor this problem, based on a historical year (HY) and a historical value (HV) in dollars, calculate the current value using the gold (CVG) and silver (CVS) references; see the referenced problems for details and examples of those individual problems. In this case, you will be provided a weighting that will range from 0 to 1, where 0 indicates complete weighting by gold and 1 indicates complete weighting by silver. Remember to round the result to two decimal places. If HY is outside of the historical data range, return NaN.\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\u003eAs an example, with HY = 2000, HV = 1000, and wt = 0.4:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCVG = $4534.09 (gold standard)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCVS = $3822.36 (silver standard)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCV = (1-0.4)*4534.09 + 0.4*3822.36 = $4249.40.\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":"tag:\"dollar\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"dollar\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"dollar\"","","\"","dollar","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fa2b917e6a8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fa2b917e608\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fa2b917dd48\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fa2b917e928\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fa2b917e888\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fa2b917e7e8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fa2b917e748\u003e":"tag:\"dollar\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fa2b917e748\u003e":"tag:\"dollar\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"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":"tag:\"dollar\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"dollar\"","","\"","dollar","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fa2b917e6a8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fa2b917e608\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fa2b917dd48\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fa2b917e928\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fa2b917e888\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fa2b917e7e8\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fa2b917e748\u003e":"tag:\"dollar\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fa2b917e748\u003e":"tag:\"dollar\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":8045,"difficulty_rating":"easy-medium"},{"id":8046,"difficulty_rating":"easy-medium"},{"id":8047,"difficulty_rating":"easy-medium"}]}}