writing signal values over time to an excel sheet using Matlab Function Block

Hello everyone. I have been a little stuck with a small problem for some days now. My problem is that i have a simulink model, which consists of a Matlab Function Block, some signals as input for the matlab function block and an output. Matlab function block should take the signals as input signals, calculate the values of those signals over a period of time, and output these values in the form of a table in an excel sheet.
The variables that will be storing the values of the signals need to be persistent variables. Because matlab function block can only access each signal at each time as far as I know.
I have attached the images of the simulink model and the example excel table. Please take a look on these pictures and let me know if anyone has an idea how to do this. Thank you for your time.

3 Comments

Isn't it easier to store the variable in MATLAB workspace and then write to excel using MATLAB commands as a post simulation step using a model function callback, particularly a StopFcn? Any reason why you need to write it on the fly?
because the values of the signals over time will keep on changing and i need to preserve those values. for this purpose i am using matlab function block and the use of persistant variable should help in keeping those values preserved.
"values of the signals over time will keep on changing" Does this mean during a simulation or between simulations? Either way, I still don't understand why you cannot use a To Workspace block to log all the signals (that do change with time, you can log them as structure with time array) and once the simulation is over, run a MATLAB command to copy it to an Excel Spreadsheet.

Sign in to comment.

Answers (0)

Categories

Products

Asked:

on 30 Aug 2016

Commented:

on 1 Sep 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!