Simulink: 2001x1 Double input multiplication with clock value, results in 2001x2001 double, while a 2001x1 double is desired. How can I tackle this?

3 views (last 30 days)
I am having trouble within the simulink environment all of a sudden.
I have a model in which a 2001x1 double value is multiplied with a clock input (time variable, should be a 2001x1 double as well). But the output of the multiplication is a 2001x2001 double, which indicates that the it has multiplied each of the input values with each of the clock input values, however, I would like to have each run through of the simulation be a single multiplication of the time with the corresponding input value, so it the result becomes a 2001x1 double as well.
The simulink time (tout) also seems to be a 2001x1 double so I dont really understand what is going wrong here. Could someone please explain this?

Answers (1)

Nitin Kapgate
Nitin Kapgate on 11 Jan 2021
In your model, the clcok time is getting multiplied with each element of a vector, that's why "Why" and "Why2" are 2001*2001 vectors.
To get the desired 2001*1 output vector, you need to specify the input as a time varying output.
You can refer to the model configuration in the attached simulink model (demoModel.slx) and resolve your issue using a similar approach.
Before running the model, run the following commands in MATLAB command window:
a = 1 + zeros(2001,1); % Time varying input
t = 0:0.005:10' ; % fixed time step of 0.005 sec to get time 2001 points
Use scope to analyze the ouput of the simulation.
The solver settings are as follows (Press CTRL+E to get there):
The Data Import/Export settings are as follows:

Community Treasure Hunt

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

Start Hunting!

Translated by