Export of string into ASCII file
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Walter Roberson
el 4 de Abr. de 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?
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!