Why do I receive "Too many arguments" error when trying to export data from an app designer table as a .txt file, to a user defined file location?
조회 수: 2 (최근 30일)
이전 댓글 표시
I am attempting to write data from an app designer table, to a .txt file, which can then be saved to a user-specified file location at the touch of a button. It should be noted that the table is quite large, with a length of 16,420 values, so maybe that is causing an issue? Not sure. Here is what I have currently:
% Button pushed function: ExporttotxtButton
function ExporttotxtButtonPushed(app, event)
t1=writetable(app.UITable.Data,'Road Profile_fl.txt');
[file,path] = uiputfile('Road Profile_fl.txt');
save(fullfile(path, file), 't1','-ascii')
end
The following errors are returned:
Any advice on how to fix this, or even a different strategy to accomplish the same goal would be much appreciated. Thank you.
댓글 수: 0
채택된 답변
Voss
2024년 8월 1일
편집: Voss
2024년 8월 1일
writetable doesn't return any arguments, so that's what the error message is saying.
writetable writes a table to file. save saves variable(s) to file. Presumably you don't need to do both here.
function ExporttotxtButtonPushed(app, event)
[fn,pn] = uiputfile('Road Profile_fl.txt'); % avoid using 'path' as a variable name,
% since it is a built-in function
if isnumeric(fn) % user canceled
return % return early
end
% write the table to the user-specified file
writetable(app.UITable.Data,fullfile(pn,fn));
end
This presumes that app.UITable.Data is in fact a table, but it could be a matrix (in which case use writematrix) or a cell array (in which case use writecell).
추가 답변 (1개)
Mario Malic
2024년 8월 1일
Hi,
from the documentation writetable
writetable(T)
writetable(T,filename)
writetable(___,Name,Value)
You can see that this function has no output arguments.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!