I am trying to convert integer x
(0<=x<=3999) to Roman numeral y
.
I wrote codes for this, but I keep getting an error when I run. What is a problem of this code?
C1=['','M','MM','MMM'];
C2=['','C','CC','CCC','D','DC','DCC','DCCC','CM'];
C3=['','X','XX','XXX','XL','L','LX','LXX','LXXX','XC'];
C4=['','I','II','IV','V','VI','VII','VIII','IX'];
x=0;
for i4=1:4;
for i3=1:9;
for i2=1:9;
for i1=1:9;
if x==0
y='';
else
y=[C1{i4} C2{i3} C3{i2} C4{i1}];
x=x+1;
end
end
end
end
end