How to provide Scheduling Point to Simulink LPV block?

9 views (last 30 days)
I have a state space system array and I am defining the property SamplingGrid. How do I tell the Simulink LPV block which model to use?
As an example, consider this array of 8 state space systems with the corresponding 3 binary decision variables:
for ii = 1:8
SS_Array(:,:,ii,1) = ss(ii,ii,ii,ii);
end
Decision1 = [0 0 0 0 1 1 1 1];
Decision2 = [0 0 1 1 0 0 1 1];
Decision3 = [0 1 0 1 0 1 0 1];
SS_Array.SamplingGrid = struct('Decision1',Decision1,...
'Decision2',Decision2,...
'Decision3',Decision3);
When I print SS_Array I get as expected SS_Array(:,:,1,1) assigned to [Decision1=0, Decision2=0, Decision3=0], SS_Array(:,:,2,1) assigned to [Decision1=0, Decision2=0, Decision3=1], etc until SS_Array(:,:,8,1) assigned to [Decision1=1, Decision2=1, Decision3=1].
I bring this to Simulink into an LPV block with the interpolation method "nearest" selected:
To tell the LPV block which model to use, I supply the values of the three decision variables to the input "par". This works for all decision variables being 0 or all decision variables being 1. But for cases in between, I get unexpected behavior: When I set Decision1=0, Decision2=0, Decision3=1, I get that the LPV block chooses SS_Array(:,:,5,1), which is the wrong model. (The right model would have been SS_Array(:,:,2,1) as shown above).
What am I missing? It seems that the LPV block expects the cheduling point parameters in a certain order. How do I know in which order to supply the decision variables? Should I supply the decision variables as name-value pair for the LPV block to work? How would I do that?
Tested with Matlab 2021a

Accepted Answer

Matthias von Andrian
Matthias von Andrian on 9 May 2022
Once I asked the question, the answer showed up on the right in form of a bug report and a workaround:
Workaround:
Decision1 = [0 0 0 0 1 1 1 1];
Decision2 = [0 0 1 1 0 0 1 1];
Decision3 = [0 1 0 1 0 1 0 1];
for ii = 1:8
SS_Array(:,:,ii,1) = ss(ii,ii,ii,ii);
end
SS_Array.SamplingGrid = struct('Decision1',Decision1,...
'Decision2',Decision2,...
'Decision3',Decision3);
% Sort according to bug fix:
% https://www.mathworks.com/support/bugreports/2627715?s_tid=answers_rc2-1_p4_MLT
GridInfo = ltipack.SamplingGrid.getGridStructure(SS_Array.SamplingGrid);
SS_Array = reshape(SS_Array(:,:,GridInfo.SamplePerm),GridInfo.GridSize);

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!