This code needs to accept 5 input numbers between 10 and 100 inclusive, then display each value as they're entered, but only if it's not a duplicate of a previously entered number. Also, it needs to display all unique numbers in a 1-D vector after all 5 values have been entered.
The 1-D vector at the end is working perfectly fine, but the numbers are still displaying at the beginning as they're entered. All I need is to be able to suppress the non-unique numbers as they're entered.
Here's my code:
clear, clcM=[];M1=[];V=input('Enter a number between and including 10 and 100: ');if V>=10 && V<=100 disp(V) M(1)=V;endW=[];I=2;J=1;K=2;M(1)=V(1);while I<=5 W=input('Enter a number between and including 10 and 100: '); V(I)=W; if V(I)>=10 && V(I)<=100 disp(W) M(I)= W; else disp('Sorry, input must be between 10 & 100. Start Over') return end for K=1:I if V(I)==W(K) break end end if (K==I) disp(V(I)) M(J)= V(I); J=J+1; end I=I+1;endM=sort(M);for J=2:5 if M(J)~=M(J-1) M1=[M1 M(J)]; endendarray=[M(1) M1]
Best Answer