How to pass variables from one file to another?
Show older comments
Hello all, I have two function file in matlab (not in simulink even though the picture is in simulink. Plus, the solvers I am using to solve my optimal control problem are not compatible with simulink). I have function file for block 1 fn U=guidance(X). And 2 files for 2nd block, i.e fn X=state_propagation(U) and run file of this function. I am having troubling closing the loop, i.e. the output U(vector) from first block (function) is a input to the second function and output X from second function is the input to the first function. How can I close both these variable passing loops from one file to another. Can someone please help?
3 Comments
Do NOT use global variables, assignin, or evalin.
DB
on 2 May 2018
Stephen23
on 2 May 2018
@Divya Bhatia: using global variables makes code liable to bugs that are very hard to debug. Using evalin and assignin makes code slow, buggy, and hard to debug.
and hundreds of other threads where these topics have been discussed.
Answers (1)
Categories
Find more on Configure Simulation Conditions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!