Marietto85
Marietto85

Reputation: 29

write a txt file in a format starting vector?

I want to do the opposite of what has been explained in this question:

problems with data acquisition from MATLAB

I would pass by the vectors (eg. codeserv = [NNNNNNNNNN ....] area = [IIIIIII ....] [.........]) to create the text file with the same format as in the link, ie:

* Comment line
| Code | serv | etc. ...
* Comment line
Figures | Figures | Figures | etc. ......

We must rebuild a new drive or you can adapt the code?

Thanks for your help and information about it.

Upvotes: 1

Views: 267

Answers (2)

eactor
eactor

Reputation: 892

Here is a little sample, what should help you to save your first file out of Matlab onto your hard drive.

%some nr to integrate into the printf
num=2.0 
%opens the file: 'file_name' with write access 
f = fopen(file_name,'w');
%writes some text into the file
fprintf(f,'test-file dump\r\n');
%writes text and includes a fload number out of matlab workspace
fprintf(f,'some-float=%f \r\n', num);
%important closes the file, other wise no other program can grand write access on the file
fclose(f);

Hopefully it helps.

Upvotes: 1

zellus
zellus

Reputation: 9592

Instead of using textscan in order to scan some input, you may use fprintf for output.

Upvotes: 0

Related Questions