Simulink - Matrix assignment problem

조회 수: 4 (최근 30일)
Frank
Frank 2015년 3월 24일
답변: Jaren Devey 2018년 1월 24일
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

답변 (1개)

Jaren Devey
Jaren Devey 2018년 1월 24일
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.

카테고리

Help CenterFile Exchange에서 Array and Matrix Mathematics에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by