How do you creat one large text file?

So I have created these mini text files in matlab but I was wondering how do you create one large file with all these mini text files in it?

回答 (3 件)

Jan
Jan 2013 年 7 月 16 日
編集済み: Jan 2013 年 7 月 16 日

1 投票

Saving them to one file initially would be more efficient. But let's try:
List = {'KuKaBand.txt', 'KaBand.txt', 'KuBand.txt', 'Noise.txt'};
OutFID = fopen(fullfile(tempdir, 'Total.txt'), 'w');
if OutFID == -1, error('Cannot open file'); end
for k = 1:numel(List)
InFID = fopen(List{k}, 'r');
if InFID == -1, error('Cannot open file'); end
InData = fread(InFID, Inf, '*uint8');
fclose(InFID);
fwrite(OutFID, InData, 'uint8');
end
fclose(OutFID);
So the strategy is: Open the resulting file for writing. Open each file for reading and append its contents to the resulting file.
[EDITED] The operating systems have some methods also. E.g. under Windows:
Str = sprintf('%s+', List{:});
system(['copy /b ', Str(1:end-1), ' Total.txt']);
Pourya Alinezhad
Pourya Alinezhad 2013 年 7 月 15 日

0 投票

load all mini text.then save the total workspace in a new text file .

3 件のコメント

karen
karen 2013 年 7 月 15 日
sorry can you be more specific.
Pourya Alinezhad
Pourya Alinezhad 2013 年 7 月 15 日
編集済み: Pourya Alinezhad 2013 年 7 月 15 日
i know that my answer is not making sense.i want you to be more specific in your question. how did you saved them?do you know all file names ? so you can save and load them with a for loop and changing the file name .
savefile = 'pqfile.txt';
p = rand(1, 10);
q = ones(10);
save(savefile, 'p', 'q')
in above code you can change savefile in a loop.so or in a similar manner for loading files.
karen
karen 2013 年 7 月 16 日
I have files name KuKaBand.txt, KaBand.txt, KuBand.txt and Noise.txt and I'm trying to put them all in one big file.

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

Saidul islam Tanveer
Saidul islam Tanveer 2020 年 2 月 11 日

0 投票

i have 8855 rows and 1133 colums how can i convert csv to matfile

カテゴリ

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

タグ

質問済み:

2013 年 7 月 15 日

回答済み:

2020 年 2 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by