Getting Started with Scilab

1. Install and run Scilab (it is available in Ubuntu Software Center)
2. Type scinotes or  go to Applications-->SciNotes

//scalar variables
a=1+1
//expression
b=3+a^2

//Output
// show string variable in messagebox

sometext='variable b='+string(b)
messagebox(sometext)

//get current directory
path1=pwd()

//change current directory
//to where current file is saved
//at first save it as 'test'

pathname = get_absolute_file_path('test.sce')
chdir(pathname)

//get current directory again
path2=pwd()


//print sometext as output
print('out.txt',sometext)


//argument of a function
x=[-5:0.1:3]

//now the function
function y=f(x)
    if x>=0 then
        y=x^2
    else
        y=-x
    end
endfunction
//plot it
plot(x,f)


//Let's try arrays
c=[1,1;-2,3]
d=[5;2]

//solve linear system c x = d
//variant1, via Matrix Inverse

c1=c^(-1)
x1=c1*d

//variant2, very simple
x2=
c\d

//let's get and show 1-st element of array x2
messagebox(string(x2(1)))

//let's get 2nd column of array 'c'
cc=c(:,2)














https://youtu.be/N2gRYx5r5Xg


The example below shows to to build simple electrical circuit with xcos (scicos)

 https://youtu.be/d2FLcBLUub4













Next simple example shows simple hydraulic circuit





No comments:

Post a Comment