Function variables

I’ve written a function which outputs two variables and takes in 4. It follows the form of my example below. I’m using it as a function block in scilab.

[y1, y2] = myFunc(h,c,V,I)
delta = h - c
omega = V * I
y1 = delta - omega
y2 = omega - delta
endfunction

I can follow through the dialogues to include it in the xcos diagram, but when I exec it before running the simulation it errors by telling me that “h - c” is an undefined variable.

I’m not sure if this is something to do with my basic syntax (I’ve followed a dozen examples and it doesn’t do anything different that I can see) or if it’s because I’m declaring a temporary variable inline (delta). I had the same issue with a longer formula within the function (in the form y2 = (axx)-(bzz) and I ended up having to break it down into:
i1=axx
i2=bzz
y2=i1-i2
or I had the same error. Seems like something fundamental that I have missed/misinterpreted.

Halp

Hi,

please try:

function [y1, y2] = myFunc(h,c,V,I)

see help: functions - Scilab procedures and Scilab objects

Best Regards,
Philipp

Sorry, yes I was using function, and had copied it character by character from the help page and then edited it for my own use. At some point it has started to function as expected, I’ve not worked out what I changed yet, but now my second PC is claiming mingw isn’t installed so codelica blocks aren’t compiling either, I’ll report back when I’ve fixed that first!