필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
ad lyn
ad lyn 2021년 10월 28일
답변: dpb 2021년 10월 28일
fid = fopen('bbg1AR20.sig', 'r');
x = fread(fid,'int16')
oldx = zeros(256,1);
for n = 1: 256000
oldx =[x(n);oldx(1:255)];
end
  댓글 수: 1
ad lyn
ad lyn 2021년 10월 28일
thnak you
what's about the 'r' here :fid = fopen('bbg1AR20.sig', 'r')

댓글을 달려면 로그인하십시오.

채택된 답변

David Hill
David Hill 2021년 10월 28일
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

추가 답변 (1개)

dpb
dpb 2021년 10월 28일
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.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by