Which input block is used in Matlab simulink that provide random values with time? - matlab

I am a new user of Matlab Simulink and currently i am working with Fuzzy Logic Controller with Simulation. In the Simulink, i want to input the values(i highlighted in the picture below), that changes with time.
Here, i am using Uniform Random Number Block which sends four values(which i feed) at same time but i want one value must input first, then another and so on. My target is to use Scope block(the one which is highlighted in the right side) and check the output that varies with time. But with current configuration, i just input ONLY one value. Please help?

Related

How to store a specific time that a signal value is changed in another parameter in Matlab simulink?

I have two Matlab function blocks that one is producing zero signal for the other. I want to store the exact time that signal changes to one in another parameter in order to use it elsewhere.
How can I do it?
This type of functinality is achieved using a Triggered Subsystem, as per the image below,
The output of the trigger block will take on value of the input (which in this case is the simulation time) every time the trigger signal rises. Look at the parameters of the Trigger block inside the subsystem for other options such as falling edge, or both edge, triggering.

Simulink: Simulating using from file block. Choosing a variable start point

I have a control model in Simulink which consists of two blocks. One which takes some inputs and generates three signals, x,y,z as arrays (trajectory) and feeds them to the second block as reference for the control.
I would like to be able to run this using a recorded trajectory. I have simulated the trajectory (by running the simulation once) and written the data to a mat file (signals plus timestamp). I can remove the first block and feed the mat file to the second control block and it works fine.
The trajectory is a loop. My question is, I would like to be able to start the simulation at any point in the file and I am not familiar with how Simulink manages time. If I want to start from a different point what do I need to do and can I make it continuous so that if I start from point N-1 in the file it will proceed through N and back to 1,2,3 etc.
Thanks,
Bryan
If you want to start at a different time point you won't be able to directly use the .mat file that you have created. You'll need to load the data into MATLAB and change the time vector so that t=0 corresponds to the data that you do want to start with.
Since you want to repeat the sequence, you most likely want to use the Repeating Sequence block. This would require you to load the data into MATLAB (and do the time alignment) anyway.

How do I input variables into a Simulink model through MATLAB script (SimDriveline)

For my coursework project in MATLAB, I have decided to build a drive-line model within Simulink, using the SimDriveline toolbox. The idea is to get the user to input values for the various parameters that are associated with each part of the model, such as the engine or the transmission. I would like to able to write this in a MATLAB script, but I'm not sure how to assign the values that are input to the Simulink model. For instance, the stock sdl_vehicle example that comes with SimDriveline. I am aware of the sim() command, but I am still confused on how to use it properly.
Also at the end of the simulation, the program is supposed to display the graphs that are collected in the scope window. I know that in the window itself that the scope can be printed to a figure, but is it possible to print that scope to a figure through MATLAB script?
This is the first time I have ever used a program like MATLAB. I would appreciate any help I could get, many thanks in advance!
There is a simulink block called simin:
http://de.mathworks.com/help/simulink/slref/fromworkspace.html?searchHighlight=simin
I used it some days back and it worked quite well. You can use the block in your model and define some signals/varibles as input.
After that you may write a Matlab-Script with an input function to set all the previous defined input values.

import a continuous bitsream from workspace into simulink using "In" block and then buffer it using "buffer" block

how to import a bitsream form binary vector from workspace into simulink.Actually I have found that I can use simin block or In block but my binary vector is independant of time. I tried to use Const block and it works but afer that when I wanted to put my output in the Buffer block in simulink, it didn't work because the input is continuous and not discrete. So I am asking if it's a way to add time to my binary uni-dimensional without having any influence on the result?and how can I do it?
Or is there another way to import this date to avoid this problem with Buffer block?
Your screenshot shows your constant block to have a sample time of Inf. As the error message suggest, you need to change that to a discrete sample time. In addition, you should also:
check your model is using a fixed-step solver
check what time step you are using for your chosen fixed-step solver (ideally the same as your constant).
You can have multi-rate models, but you need to manage the rate transitions with Rate Transition blocks. For more details on sample times, see the documentation, in particular how to view sample time information in a Simulink model. You should probably also have a quick look at the Choose a Solver section.

Simulink From Workspace: can't use timestamps from matrix

I'm using the simulink block From Workspace to read in some audio data provided by a script. I have formatted the data in a matrix with 2 columns, the first is the timestamp and the second is the data.
In the configuration paramaters, I have specified Fixed-Step and Discrete solver. The Start time and Stop also need to be configured manually and don't seem to come from the data.
Also, in the From Workspace block configuration, I need to specify the sample time (1/44100) or I get a warning if I specify -1, to inherit from the data and then get strange sample times.
So, how can I get simulink to use only the sample times in the matrix and use the first and last timestamps as the start and stop time of the simulation?
You should be able to do what you want by doing the following:
Firstly note that your problem is by definition not fixed step, hence you cannot use a fixed-step solver, which by definition is ... fixed-step.
You must use a variable step solver.
Assuming your (2 column) input data is called simin then set the start and stop times to be simin(1,1) and simin(end,1) respectively.
In your From Workspace block set the sample time to be 0 (which should have been the default).
Also de-select the Interpolate data option; and set "Form the output after final data value by:" to zero (you won't be using anything past the end of your data set so this should be OK.
Then you need to tell the solver to take additional steps to those that it would naturally want to take.
Do this on the Data Import/Export pane of the Model Configuration Parameters.
Near the bottom of the pane there is a selection box and an edit box for doing this.
Note however that this does not prevent the solver from taking steps at other time points, it just forces it to take additional steps at the times you specify.
But because you have your From WOrkspace block to not interpolate this shouldn't be a problem either. You should put simin(:,1) in here so that the solver is guaranteed to take steps at the time points in your input data.
Note that if you want an input block that only samples at the time points in the simin time vector then the only way to do this is to write an S-function that uses the mdlGetTimeOfNextVarHit method to tell the solver what the next sample time (for this block) should be.