Why does my array do this?

조회 수: 3 (최근 30일)
George Scott
George Scott 2018년 4월 7일
답변: Aveek Podder 2018년 4월 17일
I'm tring to take the mean of a set of values and store them in an array. The problem is, instead of putting the value 'm' in the array and repeating the function, it fills the array with every consecutive integer up to 3000. Anyone got a solution?
for fileidx = 1 : numel(files)
mydata{fileidx} = importdata(fullfile(folder, files(fileidx).name));
A=1:fileidx;
A=A';
y=fft(mydata{fileidx});
c=xcorr(xf,y);
m=mean(abs(c));
B=1:m;
B=B';
end

답변 (1개)

Aveek Podder
Aveek Podder 2018년 4월 17일

Instruction 'B = 1:m' will create a vector consisting of [1,2,3,...,k] where k is [m].

I think you want to append m at the end of B. To do so use the following instruction:

B(end + 1) = m;

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by