How to run the same script but for different datafiles
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I want to run a same live script but on different datasets of the same format. I have 10 different datasets in the same format. I am using a script from Bootstrap Using Chain Ladder Method - MATLAB & Simulink (mathworks.com). I can run the script on each dataset to obtain the results. However I want to load all the 10 datasets at once and automate the process such that I run the code once and get an output with a set of 10 outputs. I am kindly requesting for assistance.
0 Commenti
Risposte (1)
John D'Errico
il 15 Lug 2023
Modificato: John D'Errico
il 15 Lug 2023
Don't write scripts. Learn to write FUNCTIONS instead.
Your function will take, as input, the NAME of the data file it wants to process. It will then do the task, and return as a result any information you want it to return and save. Store that result in a variable, possibly a matrix, a vector, a cell array or a struct as appropriate.
Now just call your function 10 times, once for each data file.
Again, all of this hinges on your learning to use MATLAB as it is designed to be used. As an alternative, suppose MATLAB had NO functions at all? That is, suppose mean, sum, even the most basic functions, were themselves just scripts. In order to use them, you would need to define a variable with a SPECIFIC name in advance. They would run, and possibly step on any variables in your workspace, and create many more that you would not use or want. A MATLAB without functions would be a useless, terribly poor language. But by not learning to use functions of your own, to write your own functions, you limit what you can do, and that limit is a terribly constraining one.
So learn to use MATLAB. That is how you will solve your problem here. Learn to write functions. Your code will be far better for it.
0 Commenti
Vedere anche
Categorie
Scopri di più su Sequence and Numeric Feature Data Workflows in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!