Prev: Eigen value decomposition
Next: HMM problems
From: Phil Goddard on 7 Jun 2010 23:58 Unless the data is going to be extracted from the db (by the model, or another application) before the simulation is finished, I'd definitely recommend dumping the data to MATLAB then using db tools from within MATLAB to do the writing to the db. (You can use either the MATLAB Database Toolbox, or the DB vendors own Java, C or text file API.) You'll find that 2 step process much faster than doing the db write one time point at a time as would occur if using an S-function. Phil.
From: Kevin McCarty on 8 Jun 2010 08:38 Sounds great Phil, and I do have the database toolkit. You wouldn't happen to know if there exists a working example and/or a complete set of instructions for what you are proposing? Kevin "Phil Goddard" <philNOSPAM(a)goddardconsulting.ca> wrote in message <hukf4c$fst$1(a)fred.mathworks.com>... > > Unless the data is going to be extracted from the db (by the model, or another application) before the simulation is finished, I'd definitely recommend dumping the data to MATLAB then using db tools from within MATLAB to do the writing to the db. > (You can use either the MATLAB Database Toolbox, or the DB vendors own Java, C or text file API.) > > You'll find that 2 step process much faster than doing the db write one time point at a time as would occur if using an S-function. > > Phil.
From: Phil Goddard on 8 Jun 2010 17:02 There are 2 distinct things you need to look at, and hence you won't find one example that covers both topics. But there's lots of doc related to each individual topic and it's not hard to see how the two fit together: 1. How to export data from Simulink. For this, have a look at the doc Simulink-> User's Guide-> Managing Data -> Importing and Export Data to the MATLAB Base Workspace 2. How to export data from MATLAB to a database (assuming you intend using the Database Toolbox). For this, have a look at the doc Database Toolbox-> User's Guide -> Using Database Toolbox Functions. Phil.
From: Kevin McCarty on 9 Jun 2010 23:30
Thanks Phil, I am a little farther along but I can't tie all the pieces together yet. I imagine it should work something like this: 1. Simulink, using a To Workspace block outputs a particular set of outputs from a subsystem 2. Simulink then calls a Matlab function to do the following: 2a. Combine the outputs with the time into a single 1xn vector 2b. Uploads the resulting vector to a database table 2c. Clears the buffer 2d. Moves to the next subsystem block 2e. Repeats from 1 All the individual pieces appear straightforward enougn but I can't see how to reference the output from simulink so I can put them all together. The output is there, I can go to the Matlab editor and type the following: mat1 = [simout.time simout.signals.values] which works fine but within Simulink the simout is no longer in scope so I can't use it. Confusing matters more is the To Workspace block says the data isn't available until the simulation is paused or stopped. I don't see either problem addressed anywhere. How do I get the data out of Simulink while it is running and how can I push it to a buffer that is within scope of the Matlab function block? Or is this approach all wet too? Thanks, Kevin "Phil Goddard" <philNOSPAM(a)goddardconsulting.ca> wrote in message <humb4c$p5q$1(a)fred.mathworks.com>... > > There are 2 distinct things you need to look at, and hence you won't find one example that covers both topics. > But there's lots of doc related to each individual topic and it's not hard to see how the two fit together: > > 1. How to export data from Simulink. > For this, have a look at the doc > Simulink-> User's Guide-> Managing Data -> Importing and Export Data to the MATLAB Base Workspace > > 2. How to export data from MATLAB to a database (assuming you intend using the Database Toolbox). > For this, have a look at the doc > Database Toolbox-> User's Guide -> Using Database Toolbox Functions. > > Phil. |