Problem using Embedded MATLAB Fcn Block in Simulink?
Show older comments
Hi,
I have simulated a DAC model using Simulink. I have used a 'To Workspace' block at the output which gives me a structure 'DAC_OUT' at the workspace out of which I need two column vectors 'DAC_OUT.time' and 'DAC_OUT.signals.values' as explained later. Now, I have created another Simulink model to evaluate the FFT of a signal, in which I have used 'From Workspace' block to pick up the signal and time values from the workspace (i have written [DAC_OUT.time DAC_OUT.signals.values] in the data field entry of 'From Workspace' block). I have also used an Embedded MATLAB Function block, in which I have embedded a code (an m-file function) to evaluate the FFT of the input signal. However, there are two input arguments of this function (input,time) which means the Embedded MATLAB Func. block will have two input ports (input and time). However, the 'From Workspace' block has only one output port containing both time stamps and signal values corresponding to them (I guess). Now, how do i connect this single output port of 'From Workspace' to two input ports for my Embedded MATLAB function?
Thanks and regards.
Accepted Answer
More Answers (1)
Fangjun Jiang
on 13 Jul 2011
0 votes
When you use the "From Workspace" block, you can directly type in DAC_OUT because it is saved by the "To Workspace" block in the format of "structure with time".
When Simulink runs simulation, it has its own clock. The time stamp within the "From Workspace" signal is to make sure the signal value aligns with the Simulink clock. If you need the clock information somewhere else like you do in the Embedded MATLAB function, you can just use the clock block from the Sources library.
Categories
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!