Change the value of a state-space block matrix each iteration using set_param
조회 수: 4 (최근 30일)
이전 댓글 표시
I want to write a for loop and each time only one element of the A matrix changes. I can set the A matrix of a state-space block in Simulink using set_param but the value argument only accepts matrices in the form '[a b;c d]'. I wrote this code but I get the error message:'Invalid setting in StateSpace block 'states' for parameter 'A''
i=5;
val = zeros(2,2);
val(1,1)=0;
val(1,2)=1;
val(2,1)=i;
val(2,2)=-2;
set_param('ESO_gui/states','A',val,'B','[1;0]','C','[1 0]','D','[0]')
댓글 수: 0
채택된 답변
Gillian Rosen
2017년 3월 15일
Hi Rafaella,
I understand that you would like to set the value of a State-Space block's parameters using 'set_param', but that you are encountering an error when you try to do so.
As you mentioned, the 'set_param' function expects a string (in ' ' marks) as input for the value of A. You are encountering this error because your current input (the 'val' matrix) is not in string form. To convert 'val' from a matrix to a string, you can use the 'mat2str' function, as shown:
>> valString = mat2str(val)
You can then use this string for your input to 'set_param'. See the documentation for 'mat2str' for more information:
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 String에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!