answersLogoWhite

0


Best Answer

x=input('Enter the roman numeral: ','s');

l=length(x);

for(i=1:l)

if(x(i)=='I')

a(i)=1;

elseif(x(i)=='V')

a(i)=5;

elseif(x(i)=='X')

a(i)=10;

elseif(x(i)=='L')

a(i)=50;

elseif(x(i)=='C')

a(i)=100;

elseif(x(i)=='D')

a(i)=500;

elseif(x(i)=='M')

a(i)=1000;

else

disp('Not a valid entry');

end

end

d=a(l);

for(i=l:-1:2)

if(a(i)>a(i-1))

d=d-a(i-1);

elseif(a(i)==a(i-1) a(i)<a(i-1))

d=d+a(i-1);

end

end

disp('The decimal equivalent is: ');

disp(d);

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you convert a roman numeral into decimal using matlab?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the roman numeral for 3485000?

There is no Roman numeral for 3485000. The largest decimal number that can be represented with Roman numerals is 4999


What is the roman numeral mmccclx?

The Roman numeral MMCCCLX represents the number 2360 in decimal form.


What is the base of the roman numeral system?

Decimal.


What is the Roman Numeral number 0?

The Roman numeral system is decimal but not directly positional and does not include a zero.


Is the roman numeral system a decimal system?

Typically no because a Roman Numeral System is one System and a Decimal System is another. EX: Decimal- 0.4 Romal- VII


What number does the Roman numeral xxxi convert to?

31.


What number does the roman numeral xxxii convert to?

32


How do you convert number into roman using C?

100 = C as a Roman numeral


When working a math problem how do you actually type the roman numeral?

The simplest solution is to convert the Roman numerals to their Hindu-Arabic equivalents, perform the maths upon them, and convert the result back to a Roman numeral.


What does the roman numeral m represent in decimal?

Nothing reallyyy!


How do you convert roman into decimal please?

If you mean as in Roman numerals then no conversions can be made because the Romans didn't use decimals but they did use fractions to a limited extent as for example the numeral S is equivalent to a 1/2


What number does Roman numeral XLV convert to?

145Improved Answer:-It is: XLV = 45