×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Matlab not recognising linebreaks

Matlab not recognising linebreaks

Matlab not recognising linebreaks

(OP)
This is probably a silly question but I am going to ask it anyway...

I have written some code that puts out an array to file, however Matlab seems not to be able to recognise the line break command ('\n') hence prints out all the data in one long line rather than as a table. Instead of a new line I get a small box character instead. I think my code is correct and the tab command ('\t') works fine.

I was wondeing whether this was a problem with Matlab or a problem with the OS and in either case how it could be fixed.

I am running Matlab 7 on a windows 2000 machine. The code section is printed below:

shunt_level_data = shunt_level_data.';
filename_out = ['TC1_' date '_shuntlevels_out.txt'];
fid_out = fopen(filename_out,'w');
count = fprintf(fid_out, '%2d\t%2d\t%2d\t%2d\t%2d\t%f\t%f\t%f\n', shunt_level_data);
status = fclose(fid_out);

RE: Matlab not recognising linebreaks

When writing a textfile, adding a 't' to the fopen command might help

CODE

fid_out = fopen(filename_out,'wt');

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources