summaryrefslogtreecommitdiff
path: root/code_devel.md
diff options
context:
space:
mode:
authormanojgudi2014-03-15 22:31:48 +0530
committermanojgudi2014-03-15 22:31:48 +0530
commit6afb5cb9474faa0449b2395c2bdc8a710647ee62 (patch)
tree551fc1c6dd4813f98cdacbde6e1a331a0a37b325 /code_devel.md
parent46a716ccd44923e42823527f003eafaadc56172d (diff)
downloadsandhi-docs-6afb5cb9474faa0449b2395c2bdc8a710647ee62.tar.gz
sandhi-docs-6afb5cb9474faa0449b2395c2bdc8a710647ee62.tar.bz2
sandhi-docs-6afb5cb9474faa0449b2395c2bdc8a710647ee62.zip
finished code_devel.md
Diffstat (limited to 'code_devel.md')
-rw-r--r--code_devel.md23
1 files changed, 21 insertions, 2 deletions
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 <br>
+1. By importing Scilab to use pre-built functions<br>
```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<br>
+```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