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

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?

2 Comments

Please attach the Simulink model so we can help diagnose.
Do you require the matlab script as well? It is part of a bigger script, so I can't easily share it.

Sign in to comment.

Answers (1)

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:

Categories

Find more on Simulink in Help Center and File Exchange

Products

Release

R2020a

Asked:

on 28 Dec 2020

Answered:

on 11 Jan 2021

Community Treasure Hunt

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

Start Hunting!