Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP how do i write data into txt file

Status
Not open for further replies.

zephilly

Mechanical
Joined
Oct 10, 2013
Messages
1
Location
US
i want to write data into a txt file like

x = 0:.1:1;
A = [x; exp(x)];
fileID= fopen('exp.txt','w');
fprintf(fileID,'%6s %12s\n','x','exp(x)');
fprintf(fileID,'%6.2f %12.8f\n',A);
fclose(fileID);

But it always show that Error using fprintf Invalid file identifier. Use fopen to generate a valid file identifier.

Why i can't run this simple program!

Plz help.
 
I tested your script and it seems to work fine. Did you try clearing the variables in memory before running it? Are you running the file in a directory where you don't have write access?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top