write table into txt file using writetable returns error

4 ビュー (過去 30 日間)
Khairul nur
Khairul nur 2021 年 2 月 4 日
コメント済み: Khairul nur 2021 年 2 月 5 日
i have this in my main, and its return a table called 'step2_result_euclidean' contains a table. This function may be used fews time and each being called i want to save it into a txt file for monitoring
for ccc=1:k
step2_euclidean = kira_euclidean(data,step1_result_centroid,ccc);
result_step2=array2table(step2_euclidean);
step2_result_euclidean(:,ccc)=result_step2(:,end) ;
end
push_result(step2_result_euclidean);
This is my push_result function code:
function[]= push_result(data_to_be_push)
writetable(data_to_be_push,'result.dat''Delimiter',' ')
However, i get this error:
Error using writetable (line 124)
Wrong number of arguments.
How to fix this error? TQIA

回答 (1 件)

Cris LaPierre
Cris LaPierre 2021 年 2 月 4 日
It looks like you have a syntax error when you call writetable. You need to separate each input with a comma. You are missing a comma between your file name and the name of your Name-Value pair. Try this.
function[]= push_result(data_to_be_push)
writetable(data_to_be_push,'result.dat','Delimiter',' ')
  11 件のコメント
Walter Roberson
Walter Roberson 2021 年 2 月 4 日
fmt = [repmat('%.18g ', 1, size(data_to_be_push,2)-1), '%.18g\n'];
I had an error in the variable name, as 'data_to_be_pushed' is more natural than 'data_to_be_push'
Khairul nur
Khairul nur 2021 年 2 月 5 日
hihi..ok..the variable 'pushed'..i overlook on this as trying so hard to understand repmat function 18g or 17g..and its work! ur are great in matlab Mr. Walter and helpfull too.. :)

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by