MATLAB: Edit and run a script with another script

editin aMATLABrunscript

I need to use two scripts that are part of a packaged program many, many times in a row, so I'd like to find a way to essentially put them in a loop. More specfically, I need to open hawt_params.m, change the variable blade_params.pitch, save it, then open create_hawt.m, change the entry in arg_list{3}, and then run it. I did some searching and it seems the usual advice for such questions is to write functions and not scripts, which, of course, would make this trivial. I'd really rather not try to convert someone else's scripts into function, though (unless that's easier than I'm imagining). I'll admit that I, myself, am a script writer, so perhaps the barrier is more mental. Anyway, I'm looking for overall efficiency of the task, so, if there's a way to get it done with the existing scripts, I'd love to learn how. Thanks.

Best Answer

I found a way. I just copied and pasted the two existing scripts into a new one and created a loop around them. Pretty easy, but still curious if there's any functionality for scripts to interact with each other.