How can I import a block with a logical code in Xcos?

41 views Asked by At

I would like to make a block with this logical, where y1 is the output and u1 is the input. See:

if u1>18 then 
    y1=0.05;
elseif u1<-18 then y1=-0.05;
else y1=0
end

I tried to use the 'Switch Dynamic' block, but it only accepts a single input higher than a certain value and cannot handle two comparison values.

1

There are 1 answers

1
Rajesh On

I have not worked in XCos. However, I have some experience in Graphical Simulation tool called Simulink which I believe is similar to XCos. In simulink, you can use MATLAB block wherein you can add your matlab script similar to one shown in your above post. No of inputs for the block is same as the no of input params defined in the script

Similarly XCos may also have script block feature, where in you can create conditional block using multiple inputs. Please check how to use Script block