How to pass a variable from one file to another?
Mostra commenti meno recenti
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 Commenti
Easwar Kumar Yarrabikki
il 20 Feb 2017
When you say It Didn't work, How was the error looks like...?
Ismaeel
il 20 Feb 2017
Ismaeel
il 20 Feb 2017
Risposta accettata
Più risposte (1)
Ismaeel
il 20 Feb 2017
0 voti
Categorie
Scopri di più su Simulink in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!