Printing NetList on Notepad in a proper format

2 ビュー (過去 30 日間)
Himanshi Rani
Himanshi Rani 2017 年 9 月 19 日
コメント済み: Walter Roberson 2017 年 9 月 20 日
Hi, I have generated a SPICE NetList as a 4 column table in Matlab. When I print it to a text file using 'writetable' command,the columns in the text file generated are very haphazard. I want the output text file to contain the table in the same format as is given by the command window output, like a neat matrix.

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 9 月 19 日
nrow = size(YourTable, 1);
fid = fopen('YourOutputFile.txt', 'wt');
for K = 1 : nrow
fprintf(fid, '%-20s %-20s %8f %8f\n', YourTable{K,1}, YourTable{K,2}, YourTable{K,3}, YourTable{K,4});
end
fclose(fid);
  3 件のコメント
Himanshi Rani
Himanshi Rani 2017 年 9 月 20 日
編集済み: Himanshi Rani 2017 年 9 月 20 日
I get an error in the fprintf as 'Error using fprintf: Function is not defined for 'cell' inputs.' I am using Matlab 2016a. What is the reason for this and how to rectify it?
Walter Roberson
Walter Roberson 2017 年 9 月 20 日
Either you accidentally used YourTable(K,1) instead of YourTable{K,1} or else your table contains cell arrays inside the entries. If it does contain cell arrays inside the entries then you need to define how you want those multiple entries to be saved.
It would help if we had a representative sample of your table.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by