# MATLAB: How to return variables from table

arraysindexingnot cell arraytable

Hello, this question might seem little bit sily. Here is the thing I have table with data (5 columns), I want to return not only rows in which logical funcionts says 1 but and precending and next rows. Could someone tell me how to do that, thanks.

idx1 = find(ismember(tableName.variableName,[1 2 3])); % Apply your logic here.
idx2 = unique([idx1; idx1-1; idx1+1])
idx2 = max(1,idx2);idx2 = min(size(tableName,1),idx2);idx2 = unique(idx2); % Might have double-counted the first and last row, so get rid of those. (Could do this better)