Is it possible remove a data point when the logical index removes a coordinate?

1 view (last 30 days)
Ruth Ronalter
Ruth Ronalter on 2 Aug 2021
Commented: Ruth Ronalter on 3 Aug 2021
Hello,
I'm trying to create a scatter plot with coordinates for fixations from an excel table. Trying to create a region of interest that's a certain number of pixels big by logically removing the coordinates outside of the main area. I got a .
%step 3:filter verified saccades for only those that appear in the target areas
rawdata = readtable('RES_IAS (1).xlsx');
fix_data = rawdata(:,3:4); %extract the fixation coordinates from raw data
fix_x = table2array(fix_data(1:end,1)); %extracted X-coordinates to array
fix_y = table2array(fix_data(1:end,2)); %extracted y-coordinates to array
idx2 = fix_x > 0; fix_x < 925 %logical index for x
idx3 = fix_y > 0; fix_y < 925 %logical index for y
result1 = [fix_x(idx2) fix_y(idx3)]; %combined x and y coordinates
The code below outputs a scatterplot, I'd like to increase the filter to include a sort of border all the way around the edges (about 150 pixels)
%figure 3: fixations within ROI
x1 = fix_x(idx2)
y1 = fix_y(idx3)
figure;
scatter(x1,y1)
xlabel('X coordinates of fixations (px)'), ylabel('Y coordinates of fixations(px)'), title('Areas of fixation')
I'm aware that it's a bit redundant to have 2 indexes of the same value, but if I try to combine them into a single index like
idx2= fix_x, fix_y > 0
outputs "error:Array indices must be positive integers or logical values".
The index currently only filters a single data point at 0,0. I want to increase the size of the index, say, 95 pixels minimum, but while it removes the Y coordinates, the X-coordinates aren't removed and then I get
"Error using horzcat. Dimensions of arrays being concatenated are not consistent."
Is there a way to get both sets of values removed from the arrays? Or will it need to be edited directly from the table?

Accepted Answer

Matt J
Matt J on 2 Aug 2021
region=x1>0 & x1<925 & y1>0 & y1<925;
scatter( x1(region),y1(region) )
  1 Comment
Ruth Ronalter
Ruth Ronalter on 3 Aug 2021
Thanks, I didn't think to make the 'and' an &. Actually was able to edit out about 4 variables (I have a lot for this project), and made the filter closer to the size of my actual regions of interest

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by