How to pass a variable from one file to another?
Show older comments
Hi all, I have a matlab function block in Simulink with a feedback. The input to the function is a constant that changes with the time. The function calls another function includes ode15s (File1) that must get their equations from another file (File2). I want to pass the value of B from the main matlab function file to File2 to be used there. I used global but that did not work. Any idea?
Matlab Function File:
function y = fcn(B)
...
y=File1
%-----------------------------
File 1
function [t,x]=File1
....
[t,x] = ode15s(@File2,tspan,x0,opt);
%-----------------------------------
File2
function out= File2(t,x)
...
out=[some equations that use "B" as a constant]
%-----------------------------------------------------

%
3 Comments
Easwar Kumar Yarrabikki
on 20 Feb 2017
When you say It Didn't work, How was the error looks like...?
Ismaeel
on 20 Feb 2017
Ismaeel
on 20 Feb 2017
Accepted Answer
More Answers (1)
Ismaeel
on 20 Feb 2017
0 votes
Categories
Find more on Event Functions 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!