Save workspace data in text format

I developed a script in matlab with a code where the goal is to find a group of coordinates and other stuff...
With the information that I get from the MATLAB program I want to create a notepad like the one in the image bellow
Capturar.PNG
Is a lot of text and information in a notepad... How can I create a file like this from the program information?

4 Comments

Use fprintf:
Be prepared to do a lot of experimentation and reading the documentation!
Guillaume
Guillaume on 5 Apr 2019
Edited: Guillaume on 5 Apr 2019
Yes, I'm with Stephen, this is not going to be fun to write. Do you really have to use that format? It's really not an efficient storage format and parsing it back with matlab (if that's ever required) won't be fun either.
One thing to bear in mind is that your desired text file contains non-ASCII characters (your weird underlined degree symbol which may be an underlined masculine ordinal indicator, degree symbol should not be underlined). You're going to have to figure out which character encoding you're supposed to be using with that file, otherwise whatever is reading it may not read it correctly.
Presumably, you have documentation of the encoding and full details of the required file structure.
yes, unfortunally it has to be writen in notepad because I will use the notepad to run a solver.
Well... I guess I'll have to embrace the challenge
I'm not sure what you mean by written in notepad. The notepad program that comes with Windows is just a very simple program that allows you to view text files. It's not a particularly good one at that. I assume that you mean it has to be written as text and in the particular format that you give.
Since you don't appear to be very familiar with text files, I'll repeat my warning about character encoding. Every text file assumes a character encoding. The 3 most common ones (for english language) are ASCII, Unicode (which has 3 variants) and if on Windows, the local character encoding, most likely Windows 1252. If you write text in one encoding but the reader assumes a different encoding, some characters will be read wrong. Letters, numbers and basic punctuation is usually the same in all encodings but that weird degree symbol in your screenshot is sure to be particular to one encoding.

Sign in to comment.

Answers (0)

Categories

Asked:

on 5 Apr 2019

Commented:

on 5 Apr 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!