MATLAB: Uning Only Interger Values

arrayMATLAB

I am trying to index an array based on several values, using another array(Dt). This means I need to make sure all my values in Dt being used to index are interger values so I need to remove the values that are not intergers from Dt. Is there a way to do this directly?
Alternatively as Dt is being generated by Dt = Tf/nSteps; where Tf is a constant and nSteps = 1:1:20; is there a way to insure Dt only takes the interger values of Tf/nSteps?
Any help is appreciated.

Best Answer

You could use round(), floor(), ceil() to first round the floats to integers and then use unique() to remove possible duplicates
Tf = 500; %constant
nSteps = 1:1:20; %steps
Dt = Tf./nSteps
unique(round(Dt))
ans =
25 26 28 29 31 33 36 38 42 45 50 56 63 71 83 100 125 167 250 500