How to pass a variable from one file to another?
Ältere Kommentare anzeigen
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 Kommentare
Easwar Kumar Yarrabikki
am 20 Feb. 2017
When you say It Didn't work, How was the error looks like...?
Ismaeel
am 20 Feb. 2017
Ismaeel
am 20 Feb. 2017
Akzeptierte Antwort
Weitere Antworten (1)
Ismaeel
am 20 Feb. 2017
0 Stimmen
Kategorien
Mehr zu Programming finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!