Info

This question is closed. Reopen it to edit or answer.

How do I use simulink for a function then import it into a mat file

2 views (last 30 days)
I want to use simulink to process this equation (y=x.^3+2*x.^2+5*x+6+50*rand). everytime I run the simulink it results with a vector that is way to long. The vector being used for x is just [1 2 3 4]. The vector that is exported to my matfile is really long. This is what my simulink looks likeScreen Shot 2018-12-06 at 4.57.04 PM.png
  3 Comments
Shubham Gupta
Shubham Gupta on 7 Dec 2018
May I know, what is youar start time, stop time and Time-Step ?
If ength of your time matrix is same as the output length then you can adjust the length of the output time matrix, by adjusting start time and stop time, to get the desired length of the Output.
I hope this helps :)
Blake Tangora
Blake Tangora on 7 Dec 2018
The start time is 0 step is 0.2 and stop time is 20 but all i want the output to be is the result of the function y=x.^3+2*x.^2+5*x+6+50*rand

Answers (1)

Shubham Gupta
Shubham Gupta on 7 Dec 2018
Edited: Shubham Gupta on 7 Dec 2018
If you want output of 1x4 matrix, which will tell you the polynomial value of each corresponding element of X matrix, then you can simply set start time 0 time step 1 and stop time 0.99. This will allow simulink to run only 1 time i.e. at time = 0 after next 'time step' it will reach stop time and it won't run for time =1. So, you will get desired answer.
Another way is if you don't want to store the output and only want to display, then you can use "Display" block from simulink Library. (In this case you don't have to adjust time parameters.)

This question is closed.

Tags

Community Treasure Hunt

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

Start Hunting!