Simulink - Matrix assignment problem

5 views (last 30 days)
Frank
Frank on 24 Mar 2015
Answered: Jaren Devey on 24 Jan 2018
Hello,
I'm currenttly facing a problem, that I'm not able to solve.
The image shows a simple example of my problem. I have a 2D-matrix that I want to fill with values using a for loop. But as you can see the matrix is not filled with the values I expected. What am I doing wrong? Surprisingly for me is, that the assignment of a 1D-vector is working correctly. To solve the problem, I can not use a matlab function block because this is not allowed for my work.
Thanks in advance.
Best Regards
Frank

Answers (1)

Jaren Devey
Jaren Devey on 24 Jan 2018
So the main issue you are experiencing is related to the for loop paired with the assignment blocks. When an assignment block is placed in a for loop the first Y0 value that is entered into the assignment block is used throughout every iteration, that's why you are getting the three in the upper left corner in your displayed data, because the first Y0 into the "Assignment1" block is the first output of the "Assignment" block. Now on to the solution for the problem you show above. Utilize the two dimensional functionality of the assignment block by saying that you want these values in both columns. See the image attached for the solution.

Categories

Find more on General Applications in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!