Azzera filtri
Azzera filtri

what does the "oldx =[x(n);oldx(1:256)]" in the following programm do?

2 visualizzazioni (ultimi 30 giorni)
fid = fopen('bbg1AR20.sig', 'r');
x = fread(fid,'int16')
oldx = zeros(256,1);
for n = 1: 256000
oldx =[x(n);oldx(1:255)];
end

Risposta accettata

David Hill
David Hill il 28 Ott 2021
for n = 1: 256000
oldx =[x(n);oldx(1:255)];%just reforming the oldx array with x(n) on top and then the next 255 elements of oldx and dropping the last element
end

Più risposte (1)

dpb
dpb il 28 Ott 2021
It will (very inefficiently) append the first 255 elements of the (NEW and this is key) oldx vector onto the value of the read-in vector x after the Nth element, replacing the entire oldx vector on every pass through the loop. But, it is reversing x as it prepends it in front of the newly created vector each pass.
Whether this is the intent or not is probably debatable, but the above result is simply written as
oldx=[flipud(x);zeros(255,1)];
One might make presumptions of what was really intended, but that's what it does.

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by