Info

This question is closed. Reopen it to edit or answer.

How to Delete Numorous Large Portions of an Array

1 view (last 30 days)
P.
P. on 12 Nov 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
I have an array, A, that is 83000x1. It's 41 data sets of 2000 cells each separated by 25 cells. So what I'm asking is how can I delete those 25 cells before each data set. I know I can use indices, but I'm terrible with for loops and can't for the life of me create an indices (index...?) with all 41 sets of 25 that need to be deleted.
Here is what I have:
A = xlsread('Lab_A05_A_XD_15','B127:B83126');
ind = [2001:2025 4001:4025];
A(ind) = [];
N = 41*2000;
V = reshape(A(1:N),2000,[]);
Thanks!

Answers (2)

Geoff Hayes
Geoff Hayes on 13 Nov 2014
Edited: Geoff Hayes on 13 Nov 2014
P - it seems that you have the right idea in creating the vector ind of indices that you wish to remove. Try the following loop to create the set of indices for you
ind = [];
for k=2000:2000:83000
ind = [ind ; (1:25)'+k];
end
which will create a 1025x1 column vector of indices that are grouped as you have shown above: 2001 to 2025, 4001 to 4025, etc. In the above code, we start at 2000 and increment by 2000 at each iteration of the for loop until we reach 83000. In the body of the loop, we just create a row vector of the integers 1 through to 25, and add k to it (where k is 2000, 4000, 6000, etc.).
Then do
A(ind) = [];
and all of your 25 cells between each of the sets of 2000 cells should be deleted.

Star Strider
Star Strider on 13 Nov 2014
That’s a bit different from your Question Create an Array of Vectors from Existing Vector yesterday.
If you are talking about the same data set, create your (2000x41) data matrix this way:
M = reshape(x(~isnan(x)), [], 41);
I tested it on a simulated data set of the sort you described yesterday, and it gives the correct result.

Community Treasure Hunt

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

Start Hunting!