Simscape MultibodyにおいてS-Function Builder内でswitch case文は使えますか?
Afficher commentaires plus anciens
void test1_Outputs_wrapper(const real_T *count,
const real_T *height,
const real_T *angle,
real_T *bit)
{
switch(case_number){
case 0:
if(*count<0.5){
*bit=0;
}else{
case_number=1;
}
break;
case 1:
if(0.5<=*count){
*bit=1024;
}else{
case_number=0;
}
break;
case 2:
if(1<*height){
*bit=-1023;
}else{
*bit=0;
}
break;
現在,Simuscape MultibodyでS-Function Builderを用いてアクチュエータに命令を出したいのですが「*count」という時間を入力しているものの上記のプログラム内で反映されません.CLOCKでの入力ではダメなのでしょうか?

4 commentaires
Toshinobu Shintai
le 14 Sep 2019
ブロックの入力の「count」に入力した結果がS-Function内で反映されていないということでしょうか?
その場合、switch caseとは関係ありませんので、「*count」周りだけを記述してデバッグされてはどうでしょうか。
minato tohjima
le 16 Sep 2019
minato tohjima
le 4 Oct 2019
Toshinobu Shintai
le 5 Oct 2019
添付ファイルにS-Function Builderでsiwtch caseを使った例を作成しました。バージョンはR2019bです。私の環境では問題なく機能しています。
ちなみに私は一番最初にminato_tohjima様が貼り付けたCコードを読み込んではいませんので、そのコードが意図した通りに記述されているか、については私は知りません。C言語のコンパイラの不具合の可能性もあるので、その場合はMATLAB側では対処できません。
もしC言語の文法に関する質問に発展するようであれば、C言語のコミュニティで質問してください(MATLAB Answersではしないように)。
また、S-Function Builderのさらなる使い方についての質問に発展するようであれば、まずは他のAnswersを確認し、その質問が存在していないようであれば、新規に質問を作成してください。
Réponses (0)
Catégories
En savoir plus sur モデルのインポート dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!