Export of string into ASCII file
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 4 Apr. 2011
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?
Siehe auch
Kategorien
Mehr zu String Parsing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!