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

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 help >> Xcos > Batch functions > xcos_simulate

xcos_simulate

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

呼び出し手順

Info=xcos_simulate(scs_m, needcompile)

引数

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

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

モジュール

説明

この関数は,xcosダイアグラムをバッチモードでシミュレートする際に 使用されます. この関数は,.xcosファイルを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.xcosにある xcosダイアグラム.

このダイアグラムをバッチモードで実行し, いくつかのコンテキスト値を変更します.
importXcosDiagram("SCI/modules/xcos/demos/batch_simulation.xcos")

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.xcos")

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.xcos

このダイアグラムをバッチモードでシミュレートし, post_xcos_simulateにより伝達関数のボード線図をプロットします,
importXcosDiagram("SCI/modules/xcos/demos/Command.xcos")

// 全ての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 = eval(exprs(1));
    den = eval(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.xcos

このダイアグラムをバッチモードでシミュレートし, post_xcos_simulateにより伝達関数のボード線図をプロットします,
importXcosDiagram("SCI/modules/xcos/demos/Command_bode.xcos")

// 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 = eval(exprs(1));
    den = eval(exprs(2));
    h = syslin('c', num/den);
    // 新しい図を開き,ボード線図をプロット
    scf(max(winsid())+1);
    bode(h, 0.01, 100);

    // ボード線図のプロットの後で停止します. シミュレーションは行いません.
    continueSimulation = %f;
endfunction

xcos_simulate(scs_m, 4);

Report an issue
<< xcosValidateCompareBlock Batch functions scilab_data_structures >>

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:
Mon Oct 01 17:40:36 CEST 2012