MATRIXx

cancel
Showing results for 
Search instead for 
Did you mean: 

How to initialize a simulation?

Page 192 of the SystemBuild guide states that I must have a set of input values for each external input at each time step of the simulation. Is this correct? I would like to specify the set of inputs once and have it valid for the entire simulation time. If it is possible to specify only once, then how do I do it?
0 Kudos
Message 1 of 5
(7,831 Views)
Sure, you can have them set to zero or one or some other input data or function. For a single input system you would define a time vector say: t=[0:0.001:10]'; Then for the single input you would define u of the same dimention and say a value of one using u=ones(t); If you had a multiple input system then that would form a matrix say u1=[u,u]; for two inputs. if you wanted something different in the second input like a sine wave then you would define u2=sin(t); u1=[u,u2]; Then when you simulate you would
use t and u1 as the simulation variables.

Usually you would define this in a script in a text file like: "mysim.ms"
tf=10;
dt=0.001;
t=[0:dt:tf]';
u=ones(t);
u2=sin(t);
u1=[u,u2];
y=sim("mysuperblock", t, u, {simoptions});
grob=plot(t,y, {strip})?


I am not certain that this answers your question if not let me know.
Garrett Thurston
gthurston@foliage.com
Phone: 781.993.5540
Message 2 of 5
(7,831 Views)
Actually I solved my problem by using the "pdm" function with a u and t vector, which goes on to create the matrix. My concern is that if I have a larger system (currently mine is medium, 100 or so inputs) that the matrix will become prohibitively large for a significant run/simulation. But for now, it works.
0 Kudos
Message 3 of 5
(7,831 Views)
Nice! PDM's sometime confuse people but can be powerful for blending data and text.
Garrett Thurston
gthurston@foliage.com
Phone: 781.993.5540
0 Kudos
Message 4 of 5
(7,831 Views)
If you have an input that is truly constant over the entire sim, consider eliminating it as an input and instead use a constant block to access a variable from the xmath workspace. This is much cleaner than creating a constant vector for an input.
0 Kudos
Message 5 of 5
(7,831 Views)