Export of string into ASCII file
7 次查看(过去 30 天)
显示 更早的评论
Hello,
% I have imported some data as txt from an ASCII file (stocks.txt)
Since I created a new variable 'Trade' with its values resulted by a code 'buysell' I want to extract it as the final column in my original ASCII. thus I create 'stocks2.txt' as below:
fid = fopen('ex2.txt','wt');
% Make output string by appending trade decision
outstr = strcat(txt{1},[' Trade';buysell]);
% Write out
fprintf(fid,'%s\n',outstr{:}); fclose(fid);
% Now I try to open (even outside Matlab) the ASCII 'stocks2.txt' but is completely blank.
The new string (outstring)is as expected, but is there any way to export it in a new txt file?
I even tried a simple Copy/ Paste to a new txt file but it doesn't work.
Sorry for the naiveness of the question but as a new user I am slightly confused even with simple applications.
Many thanks,
Panos
0 个评论
回答(1 个)
Walter Roberson
2011-4-4
What data class is buysell ? If it is a character array and txt{1} is a string, then the result of the strcat() is going to be a character array instead of a cell array.
There have been cases known where a file closed in Matlab does not become immediately available outside of Matlab. I do not know the solution to that. Which Matlab version are you using?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!