How to run the same script but for different datafiles
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
John D'Errico
el 15 de Jul. de 2023
Editada: John D'Errico
el 15 de Jul. de 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 comentarios
Ver también
Categorías
Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!