Include a Scilab function/script as a block in xcos/scicos

…衆ロ難τιáo~ 提交于 2019-11-29 18:02:04

Thanks to Rupak and Anuradha from Spoken-Tutorial IIT Bombay I found the solution. Create a Scilab function as:

function [y1, y2, ...] = myFunction(u1, u2, ...)
    // some commands ...
    yi = function(u1, u2, ...);
endfunction

and save it as myFunction.sci in your preferred location.

Then execute the function once (in editor) or run the command:

exec('path\to\myFunction.sci', -1)

in the console so it will be in the Scilab memory.

Then use the Scilab function block in your block diagram:

open the Scilab Multiple Values Request by double clocking on the block, Ctrl+B or right click and select Block Parameters ...:

Here you can specify the size of input and output matrices. For example [1,1;2,3] refers to two matrices with 1×1 and 2×3 sizes. By selecting OK the Scilab Input Value Request will open:

here you can put the function you just defined y=myFunction(u); or use any other Scilab built in syntax. Now simply select OK four times till the settings are finished.

For a more elaborate example you may follow this YouTube tutorial.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!