Writing my data to a table.

This is probably a really basic fix, but I can't get my data to write to a table. What I have is a for loop that opens a .txt file, performs some functions on it, and returns the result. What I want is for the filename, and end result, to be displayed as a table and I can't seem to get it to work. Anyone know what function would work?
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

7 件のコメント

Bob Thompson
Bob Thompson 2018 年 4 月 5 日
What exactly do you mean by "displayed as a table"? Do you mean you want to put the information in to a table class variable and display it? Or you want to print the data to a txt file in a style that looks like a table? Or you want to print the data to a file that can be read by something like Excel and organized into a table?
George Scott
George Scott 2018 年 4 月 5 日
I want something that looks like this:
fileidx, m
1, **
2, **
etc It doesn't need to be an excel file, it just needs to show all the data.
Bob Thompson
Bob Thompson 2018 年 4 月 5 日
It would be fairly easy to print something like that into a txt file (or similar format). You could use fprintf to print the file name first and then dlmwrite for the data matrix.
fprintf(fileout,fileidx)
dlmwrite(fileout,resultsmatrix,'-append') % Default delimiter is ' ' I think.
George Scott
George Scott 2018 年 4 月 5 日
What is fileout? I'm getting 'undefined'.
Walter Roberson
Walter Roberson 2018 年 4 月 5 日
out_filename = 'Output.txt';
fileout = fopen(out_filename, 'wt');
fprintf(fileout, 'fileidx, m\n');
fclose(fileout);
dlmwrite(out_filename, resultsmatrix,'-append'); %default delimiter is comma
George Scott
George Scott 2018 年 4 月 6 日
Still getting undefined, what exactly do you mean 'out_filename'?
Bob Thompson
Bob Thompson 2018 年 4 月 9 日
out_filename or fileout are variable defined in MATLAB by the script to contain the string of characters of the name of the file you would like to output the results into. It is the same basic concept as files.name except that files.name is a structure class variable and calls your input files, not your output files.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeTables についてさらに検索

タグ

質問済み:

2018 年 4 月 5 日

コメント済み:

2018 年 4 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by