
How do you use when decomp sub steps with multiline logic statements?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Desired behavior:
I want to be able to utilize multi line statements to verify something whenever one of the active steps from the test sequence is active.
- I have a test sequence block that feeds the model inputs. This test sequence block has an enumerated output that is an input to the test assessment block on the output side of the model under test. This enum is used in the test assessment when decomposition sub steps. The test assesement block is monitoring the active step in the test sequence block so it knows what verification steps go with each test sequence step.
- There are cases where multiple test sequence steps can be verified with one verification step in the test assessment block. Therefore, I want to use multiline 'or' statement in the when statements.
- If I put all the conditions on a single line of code, all the corresponding steps in the test sequence will use this one verify when statement as desired.
- If I split the logic for the when statement as shown below, the test will execute without errors. however, only the first step will use this when block but the subsequent steps will use the ELSE statement at the end of the test assessment block.

What am I doing wrong? I have tried putting the '|' at the end of the first line and tried only one ellipsis on the end of the first line rather than on both lines. I get parse errors if I try to execute with any other variation than what I have shown in the screenshot.
0 comentarios
Respuestas (1)
Altaïr
el 25 de Mzo. de 2025
Editada: Altaïr
el 25 de Mzo. de 2025
As highlighted in a MATLAB Answer, multi-line conditions in a when decomposition were not supported as of R2022b, meaning the entire condition must be specified on a single line. The reference can be found here: https://www.mathworks.com/matlabcentral/answers/2000812. This limitation persists in MATLAB R2024b as well.
Consider the example described in this page: https://www.mathworks.com/help/releases/R2021a/sltest/ug/using-when-decomposition-to-write-tests.html. The when decomposition functions correctly when the condition is kept on one line. Attempting to split the condition across multiple lines using parentheses and ellipsis can lead to errors.

To manage complex conditions, consider using auxiliary variables or functions to encapsulate parts of the condition. This approach can help maintain readability and manageability while adhering to the single-line requirement. Additionally, leveraging MATLAB's logical operators efficiently can aid in constructing comprehensive conditions without exceeding line limits.
0 comentarios
Ver también
Categorías
Más información sobre Inputs en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!