

Hi All,
I am very new to scilab , I was trying to excute this simple example where i pass degrees to xcos model and xcos returns farenit.
Please can you all help me figure out what i am doing wrong ?
Below is the functionand the error :-
global response;
response = evstr(x_dialog('What is the temp in degc?','0'))
function [t,e] = deg_far(response)
//Define Symbolic parameters
global response
loadXcosLibs()
loadScicos()
filename="C:/x2cExample/final.xcos"
result= importXcosDiagram(filename)
typeof(scs_m)
scs_m.props.tf =0;
degree = struct()
degree.time = 1;
degree.values = response;
disp("What is the temp in degc?")
disp( degree)
farhenit = struct()
scicos_simulate(scs_m,list())
disp("What is the temp in degc?")
disp( degree)
disp("What is the temp in far?")
e= farhenit.values
t=farhenit.values
disp(e)
endfunction
//Error
-->deg_far
What is the temp in degc?
time: 1
values: 23
!Evaluation problem: value not updated from context. !
! !
!Protected variable name. !
! !
!Please choose another variable name. !
NamesIval = farhenit_val;
!--error 4
Undefined variable: farhenit_val
in execstr instruction called by :
at line 53 of function do_terminate1 called by :
at line 298 of function scicos_simulate called by :
at line 16 of function deg_far called by :
deg_far
Scilab


If you are new to scilab, this is a more difficult way to call xcos. I would suggest you do the following first.
- Write a function that accepts an integer representing the degree celcius value and converts it in to Faranhite and returns it.
- Use this function from the scilab console to ensure it is working as per requirement
- Build an xcos diagram that uses a "sci-func" block to call your function. This block has the ability to call any user-defined function. See this spoken tutorial to understand what I am saying.
Rupak
Login to add comment