From 6afb5cb9474faa0449b2395c2bdc8a710647ee62 Mon Sep 17 00:00:00 2001 From: manojgudi Date: Sat, 15 Mar 2014 22:31:48 +0530 Subject: finished code_devel.md --- code_devel.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'code_devel.md') diff --git a/code_devel.md b/code_devel.md index 7c1fedd..f743c5f 100644 --- a/code_devel.md +++ b/code_devel.md @@ -53,10 +53,29 @@ To integrate it, you need to ### Coding a Sci-block This section gives hints on how to use Sciscipy in Sandhi to develop blocks. There are two ways of calling Sciscipy from work_function in python. -1. By importing Scilab
+1. By importing Scilab to use pre-built functions
```python from scilab import Scilab sci_obj = Scilab() output_items[0][:2] = sci_obj.rand(1,2) # This outputs a 1x2 Array of Random number generated by Scilab ``` - +2. By importing Sciscipy to to perform a task in scilab and then return output to python
+```python +import sciscipy + +# Function returns random number generated array computed from scilab. +def my_sci_func(x, y): + # Write your scilab code as strings + code_statement1 = "x =" + str(x) + ";" + code_statement2 = "y = " + str(y) + ";" + code_statement3 = "z = rand(x,y);" + combined_statement = code_statement1 + code_statement2 + code_statement3 + sciscipy.eval(combined_statement) + + # function return value + z = sciscipy.read("z") + return z + +output_items[0][:2] = my_sci_func(1,2) +``` +we realize this is the not the best way to code, but _if it works, it works_ \ No newline at end of file -- cgit