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

3 次查看(过去 30 天)
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?

采纳的回答

Matt J
Matt J 2021-8-2
region=x1>0 & x1<925 & y1>0 & y1<925;
scatter( x1(region),y1(region) )
  1 个评论
Ruth Ronalter
Ruth Ronalter 2021-8-3
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by