Writing results to different files

11 vues (au cours des 30 derniers jours)
Tab for Lab
Tab for Lab le 9 Nov 2015
Commenté : Tab for Lab le 9 Nov 2015
Hi,
I am trying to make a code so that when I run my function, the results get saved in different files each time I run it. So for example, I run my code the first time, the results get saved in file 1 then file 2, file 3... so on Is there a way I can accomplish this?

Réponses (1)

Stephen23
Stephen23 le 9 Nov 2015
Modifié(e) : Stephen23 le 9 Nov 2015
This is such a common question that we have a very detailed description in the wiki page, complete with example code. It has also be answered many times on this forum:
There are several different functions for saving data to text files. Picking the best one depends on the nature of your data, which you do not tell us anything about. You can find a list of these functions here:
  3 commentaires
Stephen23
Stephen23 le 9 Nov 2015
Modifié(e) : Stephen23 le 9 Nov 2015
You have not told us what x, y, and z are: are they numeric arrays, cell arrays of steings, tables, character arrays, mixed cell arrays, ...? Are they scalar, 2D, or ND arrays? Each of these requires a different approach to file writing. If you want to tell us exactly what they are, then er can help you to write them to file.
You also need to tell us the required file format, which you have not told us so far.
Tab for Lab
Tab for Lab le 9 Nov 2015
The file format I want to make is either a text file or a mat file. If I want to read the files later I believe its best that we make it a .mat file. In terms of x, y, z results I thought by default I was making them scalar quantities. Basically x, y, and z are means of certain data that I have in my main function.
The question is to first run the experiment about 3 times, and add results (mean) to a different file each time. And once I have that file I need to be able to read it in order to graph the different means every time.
so for example: x = mean (data_a) y = mean(data_b) z = mean(data_c) Now I want all 3 of these results in a different file each time I run my main function. Then I want to read those files in order to graph these 3 means. How can I do that?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Workspace Variables and MAT Files dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by