>PREVIOUS:
>Hello, this is a small part of a larger code I am writing that is supposed to give a total "value" of pieces of scrap >metal at a junk yard. The other parts are fairly straightforward, and I have had no trouble figuring them out >(involved basic statements), except for the final part.
>Anyway, A user will input a range of numbers describing things such as the "length, width, mass, etc", and then a >"value" of the piece of >metal is determined by adding up the sub scores. These numbers range from a grade of 1-5.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Thanks for the help earlier guys, but now I am getting a new error.
My new code: (the x1, x2, x3 ect are just arbitrary variables to store the sub-scores)
cond = input('Condition');switch cond case 1 x1=0; case 2 x1=5; case 3 x1=10; case 4 x1=15; case 5 x1=20; otherwise x1=0;endcolor = input('Color');switch lower(color) case {'blue' 'white'} x2 = 12; case 'red' x2 = 20; case 'pink' x2 = 2; case 'black' x2 = 15; otherwise x2 = 0;endmass= input('Mass');switch mass case 1 x3 = 8; case 2 x3= 16; case 3 x3=16; case 4 x3=20; case 5 x3=20; otherwise x3=0;endlength= input('Length: ');switch length case 1 x4=8; case 2 x4=8; case 3 x4=19; case 4 x4=19; case 5 x4=19; otherwise x4=0;endwidth= input('width: ');switch width case 1 x5=6; case 2 x5=13; case 3 x5=13; case 4 x5=18; case 5 x5=18; otherwise x5=0;endpoints=(x1)+(x2)+(x3)+(x4)+(x5);disp(['The value of that piece of scrap is ', num2str(points), ' points'])
The error "Index exceeds matrix dimensions" is occurring at every "input" line.
Best Answer