Problem 8045. Gold Standard
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 Measuring Worth.
For 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.
As an example, with HY = 2000 and HV = 1000:
- GV(HY=2000) = $280.10
- N = 1000/280.10 = 3.57 (ounces of gold)
- CV = 3.57*1270 (current $/ounce of gold) = $4534.09.
Solution Stats
Problem Comments
-
2 Comments
Solutions graph shows clearly at least two different algorithms.
Nice square wave! Assuming from the template it's more like choosing between passing vector GV unchanged or str2numing it and saving ~220 on size.
Solution Comments
Show commentsGroup

Sequences & Series III
- 15 Problems
- 38 Finishers
- Sphenic number sequence
- Sphenic number sequence
- Not square-free number sequence
- Return fibonacci sequence do not use loop and condition
- Mobius function
- Not square-free number sequence
- Mobius function
- Self-similarity 1 - Every other term
- Self-similarity 2 - Every third term
- Self-similarity 3 - Every other pair of terms
- Twin Primes
- Pattern Recognition 1 - Known Unit Length
- Pattern Recognition 2 - Known Unit Length, Various Array Length (including cell arrays)
- Pattern Recognition 3 - Variable Unit and Array Length (including cell arrays)
- Return fibonacci sequence do not use loop and condition
- Return fibonacci sequence do not use loop and condition version 2
- Gold Standard
- Gold/Silver Standard
- Weighted Gold/Silver Standard
Problem Recent Solvers54
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!