Text file has no space between elements - Filename

3 ビュー (過去 30 日間)
Andreas Georgakarakos
Andreas Georgakarakos 2017 年 5 月 5 日
コメント済み: Image Analyst 2017 年 5 月 5 日
I am trying to save a matrix (8760 x 1) to a text file. This is my code:
dlmwrite('totalenergy.txt',totalenergy,'delimiter',';','precision',4)
However, the generated text file has no space between the elements. Therefore, I get something like this:
5.845.845.655.776.016.196.286.096.045.283.99 etc.
Any ideas? Also, how can I insert a string variable into the filename of the .txt file? e.g. totalenergy_'X'.txt where X is a variable.

採用された回答

Image Analyst
Image Analyst 2017 年 5 月 5 日
That's where the lines split, and you're probably looking at it in notepad or something. Double-click on it in the Current Folder panel of MATLAB and you'll see it looks normal.
  2 件のコメント
Andreas Georgakarakos
Andreas Georgakarakos 2017 年 5 月 5 日
Thank you for your quick reply, yes I did look at it in notepad. It does look normal anywhere else. I would appreciate your thoughts on my filename question.
Thank you in advance.
Image Analyst
Image Analyst 2017 年 5 月 5 日
Use sprintf() and fullfile():
folder = 'C:\wherever';
baseFileName = sprintf('totalenergy_%d.txt', X) % where X is an integer.
baseFileName = sprintf('totalenergy_%.4f.txt', X) % where X is a double
baseFileName = sprintf('totalenergy_%s.txt', X) % where X is a string
fullFileName = fullfile(folder, baseFileName);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by