Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.2 - 日本語

Change language to:
English - Français - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilabヘルプ >> Xcos > Batch functions > xcos_simulate

xcos_simulate

xcosシミュレーションをバッチモードで実行する関数

呼び出し手順

Info=xcos_simulate(scs_m, needcompile)

引数

scs_m: ダイアグラムデータ構造体 (scs_m 構造体参照).

needcompile: 整数. 4の場合, シミュレータはダイアグラムの完全なコンパイルを実行します. それ以外は, %cpr にキャッシュされた値を使用します. (古い仕様)

説明

この関数は,xcosダイアグラムをバッチモードでシミュレートする際に 使用されます. この関数は,.zcosファイルをScilabに読み込むことにより 得られるscs_m 構造体を必要とします (importXcosDiagram参照).

ユーザはシミュレーションの前に実行される pre_xcos_simulateを定義することも可能です.

function continueSimulation=pre_xcos_simulate(scs_m, needcompile)
// 何もしない
continueSimulation = %t;
endfunction
この関数がエラーを発生した場合,エラーはトラップされ, シミュレーションは破棄されます. continueSimulation を false に設定した場合, シミュレーションは停止します.

ユーザはシミュレーションの後に実行される post_xcos_simulate関数を定義することも可能です.

function post_xcos_simulate(%cpr, scs_m, needcompile)
// 何もしない
endfunction
この関数がエラーを発生した場合,そのエラーはトラップされます.

ファイルの内容

  • SCI/modules/xcos/macros/xcos_simulate.sci

SCI/modules/xcos/demos/batch_simulation.zcosにある xcosダイアグラム.

このダイアグラムをバッチモードで実行し, いくつかのコンテキスト値を変更します.
importXcosDiagram("SCI/modules/xcos/demos/batch_simulation.zcos")
typeof(scs_m) // ダイアグラムのデータ構造体
//このダイアグラムは3つのコンテキスト変数を使用します :
//  Amplitude : sin関数の大きさ
//  Pulsation : sin関数のpulsation
//  Tf        : シミュレーション終了時間
scs_m.props.context //組込み定義
//ダイアグラムに埋め込まれたパラメータを使用した最初のバッチシミュレーション
xcos_simulate(scs_m, 4);
// 終了時間の値を変更
scs_m.props.context = ["Amplitude=2" "Pulsation=3" "Tf=10"];
xcos_simulate(scs_m, 4);
// ここでpulsationを変更
scs_m.props.context = ["Amplitude=2" "Pulsation=9" "Tf=10"];
xcos_simulate(scs_m, 4);
//get the variable created by the "from workspace block"
counter

pre_xcos_simulate関数を用いた このダイアグラムの統計的な解析

importXcosDiagram("SCI/modules/xcos/demos/batch_simulation.zcos")
typeof(scs_m) //The diagram data structure
// ダイアグラムを解析するためにpre_xcos_simulationを宣言
function continueSimulation=pre_xcos_simulate(scs_m, needcompile)
    // 全てのオブジェクトを取得
    objs = scs_m.objs;
    links = 0;
    blocks = 0;
    other = 0;
    // リンクとブロックを数える
    for i = 1:size(objs)
        currentType = typeof(objs(i));
        select (currentType)
        case "Link"
            links = links + 1;
        case "Block"
            blocks = blocks + 1;
        else
            other = other + 1;
        end
    end
        // ダイアグラムの解析結果を表示
        disp("Diagram Analysis:")
        disp("Found "+string(blocks)+" Blocks.")
        disp("Found "+string(links)+" Links.")
        disp("Found "+string(other)+" Other component.")
        // シミュレーションは行わず,ダイアグラムの解析のみを実行
        continueSimulation = %f;
    endfunction
    //ダイアグラムに埋め込まれたパラメータで最初のバッチシミュレーションを実行
    xcos_simulate(scs_m, 4);

xcosダイアグラム: SCI/modules/xcos/demos/Command.zcos

このダイアグラムをバッチモードでシミュレートし, post_xcos_simulateにより伝達関数のボード線図をプロットします,
importXcosDiagram("SCI/modules/xcos/demos/Command.zcos")
// 全てのpre_xcos_simulationを消去;
clear pre_xcos_simulate;
function post_xcos_simulate(%cpr, scs_m, needcompile)
    // 全オブジェクトを取得
    objs = scs_m.objs;
    clrBlock = [];
    // CLRブロックを探す
    for i=1:size(objs)
        if objs(i).gui == "CLR" then
            clrBlock = objs(i);
            break;
        end
    end
    // CLRが見つかったかどうかを確認
    if isempty(clrBlock) then
        disp("No CLR block found.")
        return
    end
    // exprsを取得
    exprs = clrBlock.graphics.exprs;
    s = poly(0,'s');
    num = evstr(exprs(1));
    den = evstr(exprs(2));
    h = syslin('c', num/den);
    // 新たに図をオープンし,ボード線図をプロット
    scf(max(winsid())+1);
    bode(h, 0.01, 100);
endfunction
xcos_simulate(scs_m, 4);

xcosダイアグラム: SCI/modules/xcos/demos/Command_bode.zcos

このダイアグラムをバッチモードでシミュレートし, post_xcos_simulateにより伝達関数のボード線図をプロットします,
importXcosDiagram("SCI/modules/xcos/demos/Command_bode.zcos")
// post_xcos_simulationを全て消去;
clear post_xcos_simulate;
function continueSimulation=pre_xcos_simulate(scs_m, needcompile)
    // 全オブジェクトを取得
    objs = scs_m.objs;
    clrBlock = [];
    //CLRブロックを探す
    for i=1:size(objs)
        if objs(i).gui == "CLR" then
            clrBlock = objs(i);
            break;
        end
    end
    // CLRが見つかったかどうかを確認
    if isempty(clrBlock) then
        disp("No CLR block found.")
        return
    end
    // exprsを取得
    exprs = clrBlock.graphics.exprs;
    s = poly(0,'s');
    num = evstr(exprs(1));
    den = evstr(exprs(2));
    h = syslin('c', num/den);
    // 新しい図を開き,ボード線図をプロット
    scf(max(winsid())+1);
    bode(h, 0.01, 100);
    // ボード線図のプロットの後で停止します. シミュレーションは行いません.
    continueSimulation = %f;
endfunction
xcos_simulate(scs_m, 4);

参照

  • scs_m 構造体 — scs_m構造体の定義
  • importXcosDiagram — Import a Xcos diagram on Scilab
  • scicosim — xcos (バッチ) シミュレーション関数
  • xcos — ハイブリッドシミュレータ用のブロック図エディタおよびGUI
  • steadycos — xcosダイアグラムで記述された一般の動的システムの状態変数の 定常値を見つける
  • lincos — Xcosダイアグラムにより記述された一般的な動的システムから 線形化により定義された線形状態空間モデル
Report an issue
<< steadycos Batch functions xcosValidateBlockSet >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Feb 14 15:02:19 CET 2019