Merge multiple functions+scripts in single file
22 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I am trying to group together 4 functions and 2 script files in the same file. Let's call the functions A,B,C and D and the scripts f and g. The way I want this "one-file program" to work is the following:
1) Script f calls function A.
2) Function A calls function C.
-----------------------------
3) Script g calls 2 functions: Function A and D.
4) Function A calls function B.
5) Function D calls function B.
What I want is a file which contains and does all of the above. I managed to make a function which contains functions A and D, but I can't add the others since they are called by functions A and D. I've also been doing some research on "classes" which I've never used before and don't know anything about, but from reading I'm not sure classes will do the trick (I tried them without success, but didn't try very hard)
All I want to know is if this doable or is it too complicated? And if it is doable, what should I use ? Is it classes or something else ?
Thanks a lot to anyone who helps, I've really been working very hard on this and can't seem to make the program work.
0 Commenti
Risposte (2)
Honglei Chen
il 21 Feb 2012
Modificato: John Kelly
il 26 Feb 2015
You can only declare subfunctions within a function so unless you are willing to rewrite your scripts into functions, you may not be able to achieve what you want.
Some relevant information:
0 Commenti
Jean
il 21 Feb 2012
2 Commenti
Honglei Chen
il 21 Feb 2012
I couldn't comment much as I don't see the error. However, using function name in string is always tricky. I would suggest to give function handle a try.
http://www.mathworks.com/help/techdoc/matlab_prog/f2-38133.html
Vedere anche
Categorie
Scopri di più su Whos 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!