Hi All, I am trying to save a 1x18 matrix that contains the results of my data processing all whithin the same app designer CallBack function.
The matrix is called Results and I am doing as follows at teh end of all calculations:
fname = strcat ('R',num2str (r),'S',num2str(s),'_results.txt')
save (fname, 'Results','-ascii')
However, when I check the file created it is full of zeros. I copy pasted the same script in the command windows and it works perfectly. Am I missing something? Is there a specific way to do this in app designer? I've already tried a couple of suggestions from teh web, but nothing works.
Cheers
eduardo

 채택된 답변

Rik
Rik 2020년 8월 11일

0 개 추천

If you use fprintf you have full control over the format in which your data is written. I tend to suggest avoiding save/load when dealing with files that aren't in the .mat format.
It shouldn't matter if you are in AppDesigner or not, as long as the inputs are the exact same.

댓글 수: 4

Thansk Rik, however, I am unable to get it working using fprintf. I tried as below:
fileID = strcat ('R',num2str (r),'S',num2str(s),'_results.txt');
fprintf (fileID,'%d\n',Results)
I'll apreciate you can help me if fprintf can be a solution.
Cheers
Eduardo
You need to generate a file ID with fopen:
filename=fullfile(ParentFolder,...
sprintf('R%dS%d_results.txt',r,s));
fileID=fopen(filename,'w');
fprintf(fileID,'%d\n',Results);
fclose(fileID);
Thanks a lot Rik, almost there, just need to figure out how to get a "0.000" format and tab or comma separated values.
Cheers
Eduardo
Rik
Rik 2020년 8월 11일
Look into the documentation of fprintf or sprintf. Those will explain how to create a tab character or get a specific format.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 8월 11일

댓글:

Rik
2020년 8월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by