How do you multiply one single constant value with a 1D array/matrix containing 25 values in Simulink?

Hi
I am using a constant block which contains an array of 25 elements in the form [0,1,2,3,......]. I also have another signal that contains a single value e.g. 5. I would like to multiply 5 with each of the elements in that array represented by a constant.
When I try to use the simulink product block I get an error saying "Error in port widths or dimensions. Invalid dimension has been specified for input port 1 of 'Combined/Product1'."
How do I get over this error?
Thanks

 Accepted Answer

James, simply use a Gain block (Commonly Used Blocks) and choose Element-wise multiplication (double-click to open the block). The same should work also with the Product block.

4 Comments

Sorry 5 was an example. It is not a fixed number and it changes with time and is calculated by doing arithmetic in simulink. Hence gain block would not work.
I have tried using both Element-wise multiplication and matrix and neither of them worked.
I can expand and clarify the problem to help understand it.
I have a signal that changes with time and it has a constant value. Lets call this in1. I have another constant value called power (defined in matlab) which consists of 25 values in matrix form [0,1,2,3,4,......]
I am trying to solve this problem in Simulink. I would like to Multiply in1 with each of the elements of power and give me a result in 25 elements form. I would than like to add(sum) all these 25 elements to combine it into one constant value. I need to do this for every timestep of the simulation.
in1 would be the step signal. The constant is a vector with 25 elements.
Thank you so much for your constant help in my questions. That helped a lot.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!