Clear Filters
Clear Filters

Simink 条件分岐のモデルについて

7 views (last 30 days)
哉汰
哉汰 on 16 Jan 2024
Edited: Atsushi Ueno on 20 Jan 2024
入力値CNLTの大きさに応じて1または0を返す出力A,BのモデルをSwitchと論理演算で構成したいと思っています。
イメージしている振る舞いを以下に示します。
CNLT > 30 A = 0,B = 0
CNLT > 15 && CNLT <= 30 A = 0,B = 1
CNLT <= 15 A = 1,B = 1
(変数略)
if (CNLT > 30){
A = 0;
B = 0;
}else if(CNLT > 15){
A = 0;
B = 1;
}else{
A = 1;
B = 1;
}
お手数おかけしますがご教授いただきたいです。
  1 Comment
Toshinobu Shintai
Toshinobu Shintai on 16 Jan 2024
Relational Operatorブロック、Ifブロックなどを組み合わせて作成してみてはいかがでしょうか。

Sign in to comment.

Accepted Answer

Atsushi Ueno
Atsushi Ueno on 20 Jan 2024
Edited: Atsushi Ueno on 20 Jan 2024
@Toshinobu Shintaiさんの仰る使用パターンの一つを作成してみました。
単純な信号の取扱いなら前者を使い、複雑なロジックの可読性を良くする為には後者を使うのが良いと思います。
前者の場合、Relational Operator ブロックの出力だけでもOKで(型変換は必要)、その場合 Switch ブロックは不要です。
Simulinkモデルのキャプチャシミュレーションデータインスペクター画面

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!