Creating a table then filling it with data.

조회 수: 2 (최근 30일)
George Scott
George Scott 2018년 4월 6일
답변: Jeff Miller 2018년 4월 6일
So I'm fairly sure I'm missing something obvious, but how do I create a blank table, that I can then fill with data. What I have is a program that pulls data from a file, performs some functions, then returns the new data. I need this to be done on many files. What I want is a table with the filename of the data pulled, and the end result of the functions performed on said data.
folder = ('C:/Users/The G-Man/Documents/MATLAB/SpeechRecognition/SpeechRecognition2');
files = dir(fullfile(folder, '*.txt'));
mydata = cell(1, numel(files));
for fileidx = 1 : numel(files) mydata{fileidx} = importdata(fullfile(folder, files(fileidx).name)); y=fft(mydata{fileidx}); c=xcorr(xf,y); m=mean(abs(c));
end

답변 (1개)

Jeff Miller
Jeff Miller 2018년 4월 6일
How about this:
  1. preallocate arrays to hold y, c, and m before you start the loop
  2. store the values into those arrays as you go through the loop, e.g. c(fileidx)=xcorr(xf,y);
  3. stuff everything into a table after the loop finishes, e.g., t=table(files,y,c,m)

카테고리

Help CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by