How to pass a variable from one file to another?
Mostrar comentarios más antiguos
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 comentarios
Easwar Kumar Yarrabikki
el 20 de Feb. de 2017
When you say It Didn't work, How was the error looks like...?
Ismaeel
el 20 de Feb. de 2017
Ismaeel
el 20 de Feb. de 2017
Respuesta aceptada
Más respuestas (1)
Ismaeel
el 20 de Feb. de 2017
0 votos
Categorías
Más información sobre Simulink en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!