Question: Write a MATLAB (Octave) function roman2num(s) that converts a Roman numeral to a number. Instructions: i) The numeral is contained in the string s and
Write a MATLAB (Octave) function roman2num(s) that converts a Roman numeral to a number.
Instructions: i) The numeral is contained in the string s and is capitalized. ii) You can assume that s is a valid input without checking it. iii) The characters that appear in the string s are specified in the left column of the table below. iv) Each character has a "value" according to the table. v) If the characters to the right of the given character have a value less then the character value - then it's value is added to the sum. Otherwise, it is subtracted.
numeral value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Examples : >>roman2num('II') 2 >>roman2num('XLIII') 43 More examples - in the Wikipedia article: http://en.wikipedia.org/wiki/Roman_numerals
Please be as simple as possible and complete in full.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
