Switch block with Strings as Input

22 ビュー (過去 30 日間)
Abdulrahman Alturh
Abdulrahman Alturh 2020 年 9 月 23 日
回答済み: Tilman 2023 年 5 月 25 日
Hi all,
I have a problem with using the block Switch when the Inputs are Strings.
When the control Input is set to a contant, Everything would be Okay like the following screen Shot:
But when the Control Input is set to From Spreadsheet like the following screen Shot:
Giving that I'm inserting in this Example only ones (which means the Control Signal: input1 is only ones)
the Error message is:
Input port 1 in block 'Switch' must have discrete sample time when it is a string signal or a bus signal that contains string elements.
Component:Simulink | Category:Model error
An error occurred while propagating data type 'string' from 'String Constant', output port 1.
  2 件のコメント
madhan ravi
madhan ravi 2020 年 9 月 23 日
編集済み: madhan ravi 2020 年 9 月 23 日
What are you trying to compare? I mean what do you want it to do? Illustrate with a pseudo code.
Abdulrahman Alturh
Abdulrahman Alturh 2020 年 9 月 23 日
I'm trying to generate a String, and because I can't enter it from a Spreadsheet, I'm trying to control it from an input from Spreadsheet and a switch block.

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2020 年 9 月 23 日
You are trying to use a signal that is inherently discontinuous (string) with a continuous time system. Continuous time systems need to use numeric signals for controls because Simulink must be able to interpolate their values to handle variable steps.
To use string signals you will need to switch to discrete solver.
  4 件のコメント
Abdulrahman Alturh
Abdulrahman Alturh 2020 年 9 月 23 日
That's right, and this is the acutall configuration.
Walter Roberson
Walter Roberson 2020 年 9 月 23 日
I do not know if the Zero Order Hold is considered to be discrete time for this purpose ?
Like if you were using From Workspace instead of From Spreadsheet, then it is explicitly documented that you have to provide a signal value at every time.

サインインしてコメントする。


Tilman
Tilman 2023 年 5 月 25 日
I had the same problem using string constants and in the model settings a fixed step time was declared. This was due to a simulink block (rate limiter) I added before that had by default the sample time mode "continous" and that somehow inherited the sample time mode to the string constant block. When I adpted the settings of the rate limiter, the problem was not occuring anymore

カテゴリ

Help Center および File ExchangeSources についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by