Error when debugging problem
Show older comments
Hi I have to debug the following code but I keep getting errors which i do not know how to fix.Any help will be greatfull :
clear
clc
Letters = {'A' 'B' 'C' 'D' 'E' 'F' 'G' 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' 'P' 'Q' 'R' 'S' 'T' 'U' 'W' 'X' 'Y' 'Z'};
ValueToConvert = input('Please enter the value you wish to express as a number: ');
ValueString = num2str(ValueToConvert);
Base = input('Please specify the base in which you wish to represent the value: ');
Remainders = [];
while ValueToConvert > 0
Value = 0;
while ValueToConvert >= Base
Value = Value + 1;
ValueToConvert = ValueToConvert - Base;
end
Remainders = [ValueToConvert Remainders];
Value = ValueToConvert;
clear Value Remainders
end
Number = '';
for count = 1:1:size(Remainders,2)
if Remainders(count) <= 10
Number = [Number Num2Str(Remainders(count))];
else
Number = [Number Letters(Remainders(count) - 9)];
end
end
disp(['The value ' ValueString ' is expressed by the number ' Number ' in the base-' Base ' number system.'])
Im getting the following error:
Please enter the value you wish to express as a number: 766
Please specify the base in which you wish to represent the value: 16
* _error: 'Remainders' undefined near line 18 column 31
error: called from
Tutorial6Broken at line 18 column 13_*
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!