Why is my for loop code not incrementing correctly?

2 visualizzazioni (ultimi 30 giorni)
Hi!
In the code below, the data1 matrix has 100000 data in each of the two columns. I want to read the second column and divide whole column 2 with a gap of 256. That means, I want data from 1 to 256 in one matrix and then 257 to 512 in another and so on. But, the for loop that I have used is giving me only one output of the data , ie one matrix. I want to have all these data separted with a record size of 256 in differnet tables or matrices. What am i missing here?
start= 1;
last= 256;
for n= 1:1:389
% fprintf("%d \n", n)
n = data1(start:last, 2);
start= last+1;
last= start+ 255;
end
Any help would be very much appreciated.

Risposte (1)

Walter Roberson
Walter Roberson il 15 Set 2022
N = 256;
last = floor(size(data1,2)/N) * 256;
buffered = reshape(data1(1:last, 2), N, []);
The entries will now be down columns.
| want to have all these data separted with a record size of 256 in differnet tables or matrices.
That would require creating variables dynamically, which we highly recommend not be done.

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by