How to pass a variable from one file to another?
Afficher commentaires plus anciens
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 commentaires
Easwar Kumar Yarrabikki
le 20 Fév 2017
When you say It Didn't work, How was the error looks like...?
Ismaeel
le 20 Fév 2017
Ismaeel
le 20 Fév 2017
Réponse acceptée
Plus de réponses (1)
Ismaeel
le 20 Fév 2017
0 votes
Catégories
En savoir plus sur Simulink dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!