blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 6 214 | content_id stringlengths 40 40 | detected_licenses listlengths 0 50 | license_type stringclasses 2 values | repo_name stringlengths 6 87 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 15 values | visit_date timestamp[us]date 2016-08-04 09:00:04 2023-09-05 17:18:33 | revision_date timestamp[us]date 1998-12-11 00:15:10 2023-09-02 05:42:40 | committer_date timestamp[us]date 2005-04-26 09:58:02 2023-09-02 05:42:40 | github_id int64 436k 586M ⌀ | star_events_count int64 0 12.3k | fork_events_count int64 0 6.3k | gha_license_id stringclasses 7 values | gha_event_created_at timestamp[us]date 2012-11-16 11:45:07 2023-09-14 20:45:37 ⌀ | gha_created_at timestamp[us]date 2010-03-22 23:34:58 2023-01-07 03:47:44 ⌀ | gha_language stringclasses 36 values | src_encoding stringclasses 17 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 1 class | length_bytes int64 5 10.4M | extension stringclasses 15 values | filename stringlengths 2 96 | content stringlengths 5 10.4M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0deb057dafaecca25d28372f57d9050f63cccca6 | 6813325b126713766d9778d7665c10b5ba67227b | /Chapter6/Ch_6_Eg_6.28.sci | 7421d4fba5426d523dc840b1135956643f516eee | [] | no_license | arvindrachna/Introduction_to_Scilab | 955b2063b3faa33a855d18ac41ed7e0e3ab6bd1f | 9ca5d6be99e0536ba1c08a7a1bf4ba64620ec140 | refs/heads/master | 2020-03-15T19:26:52.964755 | 2018-05-31T04:49:57 | 2018-05-31T04:49:57 | 132,308,878 | 1 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 113 | sci | Ch_6_Eg_6.28.sci | // Defining an inline function.
deff('[x,y]=myfun(a,b)',['x=a+b';'y=a-b'])
[x,y]=myfun(3,4) // function call
|
2608a286570e0daa9409e2545fac3de99cdd6ab8 | 1db0a7f58e484c067efa384b541cecee64d190ab | /macros/kaiser.sci | 5079f6ff967783f3ccba2af6ac8bdfb2dfff935a | [] | no_license | sonusharma55/Signal-Toolbox | 3eff678d177633ee8aadca7fb9782b8bd7c2f1ce | 89bfeffefc89137fe3c266d3a3e746a749bbc1e9 | refs/heads/master | 2020-03-22T21:37:22.593805 | 2018-07-12T12:35:54 | 2018-07-12T12:35:54 | 140,701,211 | 2 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 1,677 | sci | kaiser.sci | <<<<<<< HEAD
function w = kaiser (m, varargin)
//This function returns the filter coefficients of a Kaiser window.
//Calling Sequence
//w = kaiser (m)
//w = kaiser (m, beta)
=======
function w = kaiser (m, beta)
//This function returns the filter coefficients of a Kaiser window.
//Calling Sequence
//w = kaiser (m)
//w = kaiser (m, beta)
>>>>>>> 6bbb00d0f0128381ee95194cf7d008fb6504de7d
//Parameters
//m: positive integer value
//beta: real scalar value
//w: output variable, vector of real numbers
<<<<<<< HEAD
=======
>>>>>>> 6bbb00d0f0128381ee95194cf7d008fb6504de7d
//Description
//This is an Octave function.
//This function returns the filter coefficients of a Kaiser window of length m supplied as input, to the output vector w.
//The second parameter gives the stop band attenuation of the Fourier transform of the window on derivation.
<<<<<<< HEAD
//Examples
//kaiser(6,0.2)
// ans =
//
=======
//Examples
//kaiser(6,0.2)
//ans =
>>>>>>> 6bbb00d0f0128381ee95194cf7d008fb6504de7d
// 0.9900745
// 0.9964211
// 0.9996020
// 0.9996020
// 0.9964211
// 0.9900745
<<<<<<< HEAD
funcprot(0);
rhs = argn(2)
if(rhs<1 | rhs>2)
error("Wrong number of input arguments.")
end
if length(varargin)==0 then
bet = 0.5; //default value of beta is 0.5
else
bet = varargin(1);
end
w = window('kr', m, bet) //default value of beta is 0.5
w = w' ;
=======
funcprot(0);
rhs = argn(2)
if(rhs<1 | rhs>2)
error("Wrong number of input arguments.")
end
if(rhs==1)
w = callOctave("kaiser", m)
elseif(rhs==2)
w = callOctave("kaiser", m, beta)
end
>>>>>>> 6bbb00d0f0128381ee95194cf7d008fb6504de7d
endfunction
|
8cc20c6c119956874fe6dca5fb65fee729d0763a | a62e0da056102916ac0fe63d8475e3c4114f86b1 | /set14/s_Material_Science_In_Engineering_Dr._K._M._Gupta_1367.zip/Material_Science_In_Engineering_Dr._K._M._Gupta_1367/CH6/EX6.5/6_5.sce | 4ec3416d844301260c970e5c3be50150c1637380 | [] | no_license | hohiroki/Scilab_TBC | cb11e171e47a6cf15dad6594726c14443b23d512 | 98e421ab71b2e8be0c70d67cca3ecb53eeef1df6 | refs/heads/master | 2021-01-18T02:07:29.200029 | 2016-04-29T07:01:39 | 2016-04-29T07:01:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 280 | sce | 6_5.sce | errcatch(-1,"stop");mode(2);//Calulate Total no. of created vacancies
//Ex:6.5
;
;
r=1.7*10^-10;//atomic radius in m
n1=10^-3;//1mm=10^-3m
a=2*r;//in m
n=n1/a;
ed=2*10^-6;//edge dislocation in m
ns=ed/a;
nv=n*ns;
disp(nv,"Total no. of created vacancies = ");
exit();
|
d1269f35186d75f1cce1ffe2065c2422fd8de35b | 449d555969bfd7befe906877abab098c6e63a0e8 | /1976/CH3/EX3.9/Ex3_9.sce | 2c34d37d65dba75fd0571d0e4a840fb3daaf9a03 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 948 | sce | Ex3_9.sce |
//To Determine the location and magnitude of minimum voltage
//Page 114
clc;
clear;
Vs=220; //Supply Voltage at End A and B
//Different Conductor Lenghts
//From End A
L1=100;
L2=50;
L3=50;
L4=400; //Length of uniform loading
A=0.5; //Uniforming loading spread over 400m
r=0.05; // Resistance of Conductor per Km
//Different Currents drawn by various loads
I1=50;
I2=75;
I3=A*L4;
//Taking moments of all currents at A;
Ib=((I1*L1)+((L1+L2)*I2)+((L1+L2+L3+(L4/2))*I3))/(L1+L2+L3+L4);
Ia=I1+I2+I3-Ib;
//Minimum Potential Point in this case is the point where All the current from B is drawn
X=Ib/A; // Distance from B;
Y=(L1+L2+L3+L4)-X; //Distance from A;
//Minimum Potential Drop
Vmind=(2*r/1000)*((Ia*L1)+((Ia-I1)*L2)+((Ia-I1-I2)*L3)+(((Y-L1-L2-L3)*A)*((Y-L1-L2-L3)/2)));
Vmin=Vs-Vmind; //Minimum Potential
printf('The Location of The Minimum Voltage is %g m from side A and its magnitude is %g V\n',Y,Vmin)
|
8c9ed95b49cc3b90c26356ee7284c9370ea9933c | 449d555969bfd7befe906877abab098c6e63a0e8 | /3840/CH3/EX3.8/Ex3_8.sce | c965a1a1989de6c3e6d9ef9e7f8e1edeaf607fe5 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 257 | sce | Ex3_8.sce | clear
//
//
//
//Variable declaration
d=1.6 //lattice spacing(angstrom)
theta=90*%pi/180 //glancing angle(radian)
lamda=1.5 //wavelength of X-rays(angstrom)
//Calculation
n=2*d*sin(theta)/lamda //maximum order of diffraction
//Result
|
e15584d00d638e7fb2d5f382053f08d0368d903a | 449d555969bfd7befe906877abab098c6e63a0e8 | /2096/CH1/EX1.51/ex_1_51.sce | e4827185305e566b0e8c00d7de9c50875de91366 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 766 | sce | ex_1_51.sce |
//Example 1.50.d // variance
clc;
clear;
close;
//given data :
n=10;
a=39.6;
b=39.9;
c=39.7;
d=39.9;
e=40;
f=39.8;
g=39.9;
h=39.8;
i=40.4;
j=39.7;
q=(a+b+c+d+e+f+g+h+i+j)/n;
d1=a-q;
d2=b-q;
d3=c-q;
d4=d-q;
d5=e-q;
d6=f-q;
d7=g-q;
d8=h-q;
d9=i-q;
d10=j-q;
d=(abs(d1)+abs(d2)+abs(d3)+abs(d4)+abs(d5)+abs(d6)+abs(d7)+abs(d8)+abs(d9)+abs(d10))/n;
s=sqrt(((d1^2)+(d2^2)+(d3^2)+(d4^2)+(d5^2)+(d6^2)+(d7^2)+(d8^2)+(d9^2)+(d10^2))/(n-1));
r1=0.6745*s;
rm=r1/sqrt(n-1);
R=i-a;
disp(q,"the arithmetic mean,q(degree celcius) = ")
disp(s,"the standard deviation(degree celcius) = ")
disp(r1,"probable error of one reading,r1(degree celcius) = ")
disp(rm,"probable error of mean,rm(degree celcius) = ")
disp(R,"range,R(degree celcius) = ")
|
1472c323361a5072421f5dce889de4f278e03ea5 | 449d555969bfd7befe906877abab098c6e63a0e8 | /343/CH4/EX4.29/ex4_29.sce | 8515f209ce697a6813ad09a98a9ee5967c13e5a0 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 351 | sce | ex4_29.sce | clc
nm=0.98 //Assigning values to parameters
kva=15
x=1
pf=1
wi=((x*kva*pf/nm)/2-(x*kva*pf)/2)
wcu=wi
kw=2
pf=0.5
kva=kw/pf
cl1=(kva/15)*(kva/15)*wi
kw=12
pf=0.8
kva=kw/pf
cl2=0.153
kw=18
pf=0.9
kva=kw/pf
cl3=(kva/15)*(kva/15)*wi
tec=cl1*12+cl2*6+cl3*6
tei=3.672
eo=204
n=eo*100/(eo+tei+tec)
disp(n,"The efficiency is") |
e3ad5bdfa2403e633b8a8f0d137f30f94182c944 | 449d555969bfd7befe906877abab098c6e63a0e8 | /3768/CH8/EX8.9/Ex8_9.sce | 50c7d40f84c69cab8baa1dda6ba6b72a1ce0e08d | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 333 | sce | Ex8_9.sce | //Example number 8.9, Page number 173
clc;clear;
close;
//Variable declaration
A=100; //area(m**2)
B=0.01; //flux density(wb/m**2)
H=40; //magnetic field(amp/m)
M=7650; //atomic weight(kg/m**3)
//Calculation
h=A*B*H; //hysteresis loss per cycle(J/m**3)
//Result
printf("hysteresis loss per cycle is %.f J/m^3",h)
|
5e1638ec1c8c9c56905a7189850a5c30af195148 | 449d555969bfd7befe906877abab098c6e63a0e8 | /866/CH9/EX9.2/9_2.sce | 555bb2e7e7503cf8340ebdd2f58cd8e824bdf1bc | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 423 | sce | 9_2.sce | clc
//initialisation of variables
M= 100*10^6 //Nmm
BeamB= 300 //mm
BeamL= 200 //mm
BeamT= 25 //mm
BeamT2= 20 //mm
//CALCULATIONS
Iz= ((BeamL*BeamB^3)/12)-((BeamL-BeamT)*(BeamB-2*BeamT2)^3)/12
sigmaxbyY= -M/Iz
SB= sigmaxbyY*(BeamB/2)
ST= sigmaxbyY*(-BeamB/2)
//RESULTS
printf ('Stress at top of the beam= %.2fN/mm^2(Tension)',ST)
printf ('\n Stress at bottom of the beam= %.2fN/mm^2(compression)',SB)
|
66b0c2de3c6a57a4cba6ab8457cae3a2d8d7de2e | 449d555969bfd7befe906877abab098c6e63a0e8 | /1373/CH13/EX13.5/Chapter13_Example5.sce | c9ec757146acd70cf2e8aa77f0e794ad96589e4f | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 830 | sce | Chapter13_Example5.sce | //Chapter-13, Example 13.5, Page 558
//=============================================================================
clc
clear
//INPUT DATA
po2=2;//Pressure of O2 in bar
Di=0.025;//inside diamter of the pipe in m
L=0.0025;//Wall thickness in m
a=(0.21*10^-2);//Diffusivity of O2 in m^2/s
S=(3.12*10^-3);//Solubility of O2 in k.mol/m^3.bar
DAB=(0.21*10^-9);//Binary diffusion coefficient in m^2/s
//CALCULATIONS
CAi=(S*po2);//Concentration of O2 on inside surface in kmol/m^3
RmA=((log((Di+(2*L))/Di))/(2*3.14*DAB));//Diffusion resistance in sm^2
Loss=(CAi/RmA)/10^-11;//Loss of O2 by diffusion per meter length of pipe *10^-11
//OUTPUT
mprintf('Loss of O2 by diffusion per meter length of pipe is %3.2f*10^-11 kmol/s',Loss)
//=================================END OF PROGRAM==============================
|
b3e6ce2e092227377bd0d34d12be435a391c8ea9 | 449d555969bfd7befe906877abab098c6e63a0e8 | /1931/CH7/EX7.11/11.sce | bfbb7f300c3cf65bf57c7385839d77a16101b37c | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 674 | sce | 11.sce | clc
clear
//INPUT DATA
r=1.85*10^-10//the radius of sodium atom in m
t=3*10^-14//the classic value of mean free time in sec
temp=0//temperature in centigrade
na=2//number of atoms in a unit cell
ne=1//number of electrons per unit cell
e=1.6*10^-19//charge of electron in coulombs
m=9.11*10^-31//mass of a electron in kg
//CALCULATION
a=(4*r)/sqrt(3)//a is one side in bcc structure unit cell in m
v=a*a*a//volume of bcc structure unit cell in m^3
n=(na*ne)/v//density of electrons per unit volume in m^-3
r=(m/(n*e^2*t))/10^-8//The electrical resistivity in ohm metre *10^-8
//OUTPUT
printf('The electrical resistivity is %3.2f *10^-8 in ohm metre',r)
|
18d2c46b05f6bd37212d584b7b8c940ac541217c | 449d555969bfd7befe906877abab098c6e63a0e8 | /3556/CH4/EX4.18/Ex4_18.sce | 2142dd44338b038407b250c7b96099e72d6c9dde | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 909 | sce | Ex4_18.sce | clc
// Fundamental of Electric Circuit
// Charles K. Alexander and Matthew N.O Sadiku
// Mc Graw Hill of New York
// 5th Edition
// Part 1 : DC Circuits
// Chapter 4 : Circuit Theorems
// Example 4 - 18
clear; clc; close;
//
// Given data
Vs = 220.0000;
R1 = 1000.0000;
R3 = 3000.0000;
R4 = 400.0000;
R6 = 600.0000;
Rm = 40.0000;
//
// Calculations Rp1
Rp1 = (R1*R3)/(R1 + R3);
// Calculations Rp2
Rp2 = (R4*R6)/(R4 + R6);
// Calculations Rs1
Rth = Rp1 + Rp2
// Calculation Vth
V1 = (R1/(R1 + R3))*Vs;
V2 = (R6/(R4+R6))*Vs;
Vth = V1 - V2;
// Calculation IG
IG = Vth/(Rth + Rm)
//
// Display the result
disp("Example 4-18 Solution : ");
printf(" \n IG = Current Through The Galvanometer = %.3f mA",IG*1000)
|
214e52d93568ad73d6a46fb98a9efe46645e6bf6 | 449d555969bfd7befe906877abab098c6e63a0e8 | /2510/CH11/EX11.14/Ex11_14.sce | 91ab7fd9acfbab132f407bfa37807c5dacce3bfa | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 1,442 | sce | Ex11_14.sce | //Variable declaration:
T1 = 127.0+273.0 //Surface temperature (K)
T2 = 20.0+273.0 //Wall temperature (K)
T3 = 22.0+273.0 //Air temperature (K)
s = 5.669*10**-8 //Stefan-Boltzmann constant
e = 0.76 //Surface emissivity of anodized aluminium
D = 0.06 //Diameter of %pipe (m)
L = 100.0 //Length of %pipe (m)
h = 15.0 //%pipe convective heat transfer coefficient (W/m^2.K)
//Calculation:
Eb = s*T1**4 //Emissive energy of %pipe (W/m^2)
E = e*Eb //Emissive power from surface of %pipe (W/m^2)
A = %pi*D*L //Surface area of %pipe (m^2)
Qc = h*A*(T1-T3) //Convection heat transfer to air (W)
Qr = e*s*A*(T1**4-T2**4) //Radiation heat transfer rate (W)
Q = Qc+Qr //Total heat transfer rate (Btu/h)
Tav = (T1+T2)/2.0 //Average temperature (K)
hr = 4*e*s*Tav**3 //Radiation heat transfer coefficient (W/m^2.K)
//Result:
printf("The emissive power from surface of %%pipe is : %.0f W/m^2.",E)
printf("The convection heat transfer to air is : %.1f kW.",Qc/10**3)
printf("The radiation heat transfer rate is : %.1f kW",Qr/10**3)
printf("The radiation heat transfer coefficient is : %.1f W/m^2.K.",hr)
|
06e06bf15621aed111ea63df783395b621540581 | 449d555969bfd7befe906877abab098c6e63a0e8 | /3769/CH22/EX22.23/Ex22_23.sce | 5690a8582978f32b906661072af3037a1c673471 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 151 | sce | Ex22_23.sce | clear
//Given
u=1.33
a=90
//Calculation
//
ap=atan(u)*180/3.14
A=a-ap
//Result
printf("\n Angle between the sun and the horizon is %0.0f Degree",A)
|
ac59fd530e0785abb906702387bc650978f71b6b | 449d555969bfd7befe906877abab098c6e63a0e8 | /944/CH3/EX3.21/example3_21_TACC.sce | c62e80231a1a00495f036c33dc99798c7c6f242d | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 1,134 | sce | example3_21_TACC.sce | //example 3.21
clear;
clc;
//Given:
Cp1=poly([26.0, 43.5*10^-3, -148.3*10^-7],'T','c');//heat capacity for CO2(g)[J/K/mol]
Cp2=poly([30.36, 9.61*10^-3, 11.8*10^-7],'T','c');//heat capacity for H2O(g)[J/K/mol]
Cp3=poly([27.30, -5.23*10^-3, -0.04*10^-7],'T','c');//heat capacity for N2(g)[J/K/mol]
H1=-881.25;//heat of combustion of methane at 298K[KJ/mol]: CH4 + 2O2(g) --> CO2(g) + 2H2O(l)
H2=43.6;//heat of vaporization of water at 298K[KJ/mol]: H2O(l)-->H2O(g)
T1=298;//initial temperature [K]
//to find the maximum flame temperature when one mole of methane is burnt completely in calculated amount of air(N2 to O2 ratio 4),at constant pressure
H=(H1+2*H2);//enthalpy of reaction: CH4 + 2O2(g) --> CO2(g) + 2H2O(g) [KJ]
printf("H(enthalpy of reaction)=%f KJ/mol.\n",H);
printf("H(enthalpy of heating)=%f KJ/mol. \n",-H);
Cp=Cp1+2*Cp2+8*Cp3;//[J/K/mol]
P=poly([0 , 305.12 , 52.28*10^-3 , -41.66*10^-7] , 'T' , 'c');
i=horner(P,298);
c1=-H*1000+i;
P1=poly([-c1 , 305.12 , 52.28*10^-3 , -41.66*10^-7] , 'T' , 'c');
T2=roots(P1)
printf("T2 (maximum flame temperature)= %f K",T2(1)); |
bcc54312c61affd23dd3096cbc70daa91f29c78c | 449d555969bfd7befe906877abab098c6e63a0e8 | /662/CH4/EX4.20/ex4_20.sce | 246325a906f6ac468ad6723f80fe0e050782c246 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 210 | sce | ex4_20.sce | //Example 4.20
//use of the minimum field width feature
i = 12345;
x = 345.678;
printf("%3d %5d %8d\n\n", i, i, i);
printf("%3f %10f %13f\n\n", x, x, x);
printf("%3e %13e %16e", x, x, x); |
af453c0c38ef0b36a818f763d50ef2cd29325db1 | 449d555969bfd7befe906877abab098c6e63a0e8 | /1529/CH15/EX15.2/15_02.sce | 40b6b3cbdfc027ad47e592dfbc4597a507b4a94c | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 621 | sce | 15_02.sce | //Chapter 15, Problem 2
clc;
f1=50; //frequency in hertz
L1=40e-3; //inductance
V=240; //voltage
V2=100; //voltage
f2=1000; //frequency in hertz
Xl=2*%pi*f1*L1; //inductive reactance
Xl2=2*%pi*f2*L1; //inductive reactance
I=V/Xl; //current
I2=V2/Xl2; //current
printf("(a) Inductive reactance, Xl = .2%f ohm \nCurrent I = %.2f A\n\n",Xl,I);
printf("(b) Inductive reactance, Xl = %.1f ohm \nCurrent I = %.3f A\n\n",Xl2,I2);
|
8f1fd378150702dd3ddc3422890a6b604f4eabc0 | 449d555969bfd7befe906877abab098c6e63a0e8 | /3772/CH6/EX6.16/Ex6_16.sce | d11eb4225fa72846e9dacb19582bdbc6fe515ad8 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 551 | sce | Ex6_16.sce | // Problem no 6.16,Page No.171
clc;clear;
close;
E=200*10**9 //Pa
I=2500*10**-8 //m**4
//Calculations
//Taking moment about A we get
R_a=(30*5+30*1)*6**-1 //Reaction at pt A
R_b=60-R_a //Reaction at pt B
M_c=30*1 //B.M at C
M_d=30*1 //B.M at D
M_a=0 //B.M at a
M_b=0 //B.M at b
//For conjugate beam taking moment about B_dash
R_a_dash=(30*2**-1*(5+1*3**-1)+30*4*3+30*2*3**-1*2**-1)*6**-1
R_b_dash=150-R_a_dash
y_e=1*(E*I)**-1*(R_a_dash*3-30*2*1-2**-1*1*30*(2+1*3**-1))*1000
//Result
printf("Deflection at the centre is %.2f",y_e);printf(" m")
|
fb1892928a54cc5041ae64e539404a66741eb924 | 449d555969bfd7befe906877abab098c6e63a0e8 | /686/CH8/EX8.3/Ex8_3.sci | 9f231d7a6a089caeecfc4c1def9c8822e4882962 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 1,253 | sci | Ex8_3.sci | clc();
clear;
// To find the heat transfer coefficient at x = 12 in.
Tp = 176; // Temperature of plate in F
Ta = 68; // Tempearture of air stream in F
Tm = (Tp+Ta)/2; // Maen temperature in F
u = 30; // Velocity in fps
n = 19.45*10^-5; // Dynamic visosity in ft^2/sec
v = 30; // Velocity in fps
Pr = 0.703; // Prandtls number
x = 12/12; // distance in ft
k = 0.0162; // Thermal conductivity in Btu/hr-ft^2-F
Re = v*x/n; // Reynolds number
// The boundary layer must be laminar or turbulent
St = 0.0296*(Re)^-(1/5)/(1+1.75*0.87*(Re)^-(1/10)*(Pr-1)); // Strantons number
Nu = Re*Pr*St; // Nusselt number
h = Nu*k/x; // Heat transfer coefficient
printf("The heat transfer coefficient of heating of water for laminar is %.2f Btu/hr-ft^2-F",h)
// If the flow is laminar
Nu1 = 0.332*Re^(1/2)*Pr^(1/3); // Nusselt number
h1 = Nu1*k/x; // Heat transfer coefficient
printf(" \n The heat transfer coefficient for turbilent layer is %.2f Btu/hr",h1);
|
3de35237d012435082977d398952b963aefad081 | 449d555969bfd7befe906877abab098c6e63a0e8 | /3774/CH5/EX5.1/Ex5_1.sce | c6132697b70d6c9d253001cfd48998becff8f7b3 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 3,008 | sce | Ex5_1.sce | // exa 5.1 Pg 142
clc;clear;close;
// Given Data
ps=2.5;// MPa
D=1.5;//m
sigma_t=80;// MPa
tau=60;// MPa
sigma_c=120;// MPa
n=5;// no. of rivets
printf('DESIGNING LONGITUDINAL JOINT - \n')
printf('\n Plate Thickness')
eta_l=80;// % (efficiency)
t = ps*D*1000/2/sigma_t/(eta_l/100)+1;// mm
printf(', t = %.2f mm',t)
t=32;//mm (adopted for design)
printf('\n use t = %d mm',t)
printf('\n Diameter of rivet hole, do = ')
d0=6*sqrt(t);//mm (for t>8 mm)
printf('%.2f mm',d0)
d0=34.5;// suggested for design
printf('\n Use do = %.f mm',d0)
printf('\n Diameter of rivet, d = ')
d=d0-1.5;//mm
printf('%.2f mm',d)
printf('\n Pitch of rivets, p = ')
Ps=(4*1.875+1)*%pi/4*d0**2*tau;// N
// Putting Pt=Ps where Pt=(p-d0)*t*sigma_t;// N
Pt=Ps;//N
p=Pt/(t*sigma_t)+d0;// N
printf('%.1f mm',p)
C=6;// for 5 no. of rivets
pmax=C*t+40;// mm (as per IBR)
printf('\n as per IBR-\n pitch, pmax = %.f mm',pmax)
p=220;// mm (adopted for design)
printf('\n Use p = %.f mm',p)
pi=p/2;// mm
printf('\n pitch of rivets in inner row, pi = %.f mm',pi)
//Distance between rows of rivets
dis1=0.2*p+1.115*d0;// mm
printf('\n distance between outer and adjacent row = %.1f mm',dis1)
dis1=85;//mm (adopted for design)
printf('\n take & use this distance = %.f mm', dis1)
dis2=0.165*p+0.67*d0;// mm
printf('\n distance between inner row for zig-zag riveting = %.1f mm', dis2)
dis2=60;//mm (adopted for design)
printf('\n take & use this distance = %.f mm', dis2)
printf('\n Thickness of wide butt strap, t= ')
t1=0.75*t;// mm (wide butt strap)
printf(' %.f mm',t1)
t2=0.625*t;// mm (narrow butt strap)
printf('\n Thickness of narrow butt strap, t= %.f mm',t2)
//margin
m=ceil(1.5*d0);// mm
printf('\n margin, m = %.f mm',m)
// Efficiency of joint
Pt=(p-d0)*t*sigma_t;// N
Ps=Ps;// N (shearing resistance of rivets)
Pc=n*d0*t*sigma_c;// N (crushing resistance of rivets)
sigma_com = (p-2*d0)*t*sigma_t+%pi/4*d0**2*tau;// N
printf('\n strength of the joint = %d N',sigma_com)
P=p*t*sigma_t;//N (strength of solid plate)
printf('\n strength of solid plate = %d N',P)
eta_l=sigma_com/P*100;// % (efficiency)
printf('\n Efficiency of joint, eta_l = %.1f %%',eta_l)
printf('\n\n DESIGNING CIRCUMFERENTIAL JOINT- \n')
t=32;// mm
d0=34.5;//mm
d=33;//mm
printf('\n Plate Thickness')
printf(', t = %.2f mm',t)
printf('\n Diameter of rivet hole, do = ')
printf('%.2f mm',d0)
printf('\n Diameter of rivet, d = ')
printf('%.2f mm',d)
n=(D*1000/d0)**2*(ps/tau);// no. of rivets
printf('\n no. of rivets = %.1f',n)
n=80;// adopted for design
printf('\n take n = %d',n)
// Pitch of rivets
n1=n/2;// no. of rivets per row
pc=%pi*(D*1000+t)/n1;// mm (pitch of rivets)
printf('\n pitch of rivets, pc = %.2f mm\n use pc = %.f mm',pc,pc)
eta_c=(pc-d0)/pc*100;// % (efficiency of joint)
printf('\n Efficiency of joint, eta_c = %.2f %%',eta_c)
dis=0.33*pc+0.67*d0;// mm (distance between rows of rivets)
printf('\n for zig-zag riveting, distance between rows of rivets = %.1f mm. use 65 mm', dis)
m=1.5*d0;// mm (Margin)
printf('\n margin, m = %.f mm',m)
|
257c32ebcc548234077d9c2b53f7716c56680f81 | 449d555969bfd7befe906877abab098c6e63a0e8 | /3428/CH5/EX5.6/Ex5_6.sce | 52f622dfcc33e0f6c237a1ddd00cc97a2c1735b8 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 411 | sce | Ex5_6.sce | //Section-1,Example-6,Page no.-AC.164
//To calculate the quantity of air needed for complete combustion of 1 kg fuel..
clc;
W_C=720 //(gm)
W_H=50 //(gm)
W_S=30 //(gm)
W_O=40 //(gm)
WO_net=(((32/12)*W_C)+((16/2)*W_H)+((32/32)*W_S))-W_O //(gm)
M=WO_net*(100/23)*10^-3
disp(M,'mass of air needed for complete combustion(kg)')
|
fcd78109925b4699c0f5f3048bf484bd3e9d54d0 | 1bb72df9a084fe4f8c0ec39f778282eb52750801 | /test/RT31.prev.tst | ca2ffe0fea22e6dff635a6fbc15e159e1f12a1b0 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | gfis/ramath | 498adfc7a6d353d4775b33020fdf992628e3fbff | b09b48639ddd4709ffb1c729e33f6a4b9ef676b5 | refs/heads/master | 2023-08-17T00:10:37.092379 | 2023-08-04T07:48:00 | 2023-08-04T07:48:00 | 30,116,803 | 2 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 1,315 | tst | RT31.prev.tst | [0,0,0,0,0,0,0,0,0,0,1,4,6,4,1] | [1,1,1,1,2,1,1,3,3,1] =
quot[1,1] = 1, remd = [[0],[0,0],[0,0,0],[0,0,0,0],[1,4,6,4,1]], prod = [[0],[0,1],[0,1,1],[0,1,2,1],[0,1,3,3,1]]
quot[1,0] = 1, remd = [[0],[0,-1],[0,-1,-1],[0,-1,-2,-1],[1,3,3,1], prod = [[0],[1,0],[1,1,0],[1,2,1,0],[1,3,3,1]
quot[0,0] = -1, remd = [[0],[-1,-1],[-1,-2,-1],[-1,-3,-3,-1]], prod = [[-1],[-1,-1],[-1,-2,-1],[-1,-3,-3,-1]]
reduce: [[0],[0,0],[0,0,0],[0,0,0,0],[1,4,6,4,1]] / [[1],[1,1],[1,2,1],[1,3,3,1]] -> [[-1],[1,1]] rest [[1]]
quot[3,3] = 1, remd = [[1],[1,1],[1,2,1],[1,3,3,1]], prod = [[0],[0,0],[0,0,0],[0,0,0,1]]
quot[3,2] = 3, remd = [[1],[1,1],[1,2,1],[1,3,3], prod = [[0],[0,0],[0,0,0],[0,0,3]
quot[3,1] = 3, remd = [[1],[1,1],[1,2,1],[1,3], prod = [[0],[0,0],[0,0,0],[0,3]
quot[3,0] = 1, remd = [[1],[1,1],[1,2,1],[1], prod = [[0],[0,0],[0,0,0],[1]
quot[2,2] = 1, remd = [[1],[1,1],[1,2,1]], prod = [[0],[0,0],[0,0,1]]
quot[2,1] = 2, remd = [[1],[1,1],[1,2], prod = [[0],[0,0],[0,2]
quot[2,0] = 1, remd = [[1],[1,1],[1], prod = [[0],[0,0],[1]
quot[1,1] = 1, remd = [[1],[1,1]], prod = [[0],[0,1]]
quot[1,0] = 1, remd = [[1],[1], prod = [[0],[1]
quot[0,0] = 1, remd = [[1]], prod = [[1]]
reduce: [[1],[1,1],[1,2,1],[1,3,3,1]] / [[1]] -> [[1],[1,1],[1,2,1],[1,3,3,1]] rest [[0]]
reduced: [[1]]
result: [[1]]
|
e842f2420c1e7c6b1349d3c0b0fc1696440359ee | 449d555969bfd7befe906877abab098c6e63a0e8 | /527/CH4/EX4.10/4_10exam.sce | c374a867a7d39eb1fa301193165e0dae80beaa1e | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 1,301 | sce | 4_10exam.sce | //Engineering and Chemical Thermodynamics
//Example 4.10
//Page no :202
//Solution(a)
clear ; clc ;
T = 100 + 273 ; //[K]
P = 70 * 10^5 ; //[N/m^2]
P_c = 42.2 * 10 ^ 5 ;
T_c = 370 ; //[K]
w = 0.153 ;// Interpolating from table C.1 and C.2
z_0 = 0.2822 ;// Interpolating from table C.1 and C.2
z_1 = - 0.0670 ;// Interpolating from table C.1 and C.2
m = 20 * 10^3 ;//[g]
MW = 44 ; //[g/mol]
R = 8.314 ;
P_r = P / P_c ;
T_r = T / T_c ;
z = z_0 + w * z_1 ;
V = m / MW *z * R * T / P ;
disp(" Example: 4.10 Page no : 202") ;
printf("\n (1)\n Volume = %.4f m^3 \n\n", V )
//Solution(b)
T = 295 ;//[K]
n = 50 ; // [mol]
a = 0.42748 * R^2 * T_c^2.5 / P_c ;
b = 0.08664 * R * T_c / P_c ;
v = 0.1 ;
P = R * T / (v - b) - a / (T^0.5 * v * (v + b)) ;
x = P * n * 10^-6 ;
printf("\n (2)\n Pressure = %d MPa \n\n", x )
//Solution (c)
y1 = 0.4 ;
y2 = 1 - y1 ;
n = 50 ;
P_c = 48.7 * 10^5 ;//[N/m^2]
T_c = 305.5 ; //[K]
a1 = a ;
b1 = b ;
a2 = 0.42748 * R^2 * T_c^2.5 / P_c ;
b2 = 0.08664 * R * T_c / P_c ;
a_mix = y1^2 * a1 + 2 * y1 * y2 * sqrt(a1 * a2) + y2^2 * a2 ;
b_mix = y1 * b1 + y2 * b2 ;
P = R * T / (v - b_mix) - a_mix /(T^0.5 * v * (v + b_mix));
x = P * n * 10^-6 ;
printf("\n (3)\n Pressure = %.2f MPa \n\n", x ) |
96c7f72aeb631adddd79013a42b6a07d21a3e222 | 449d555969bfd7befe906877abab098c6e63a0e8 | /1652/CH14/EX14.6/14_6.sce | b1af37d426ba2c685fbd4ee4d513a2c9eeba13d9 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 236 | sce | 14_6.sce | clc
//Initialization of variables
disp("from table 14.1,")
r1=1.75*10^-5 //m
r2=1.772*10^-4 //m
mp=1.008*10^-14 //m^2
//calculations
r3=r2/r1
mH2=r3*mp
mH=sqrt(mH2)
//results
printf("Concentraton of Hplus ions = %.1e M",mH)
|
2c3f47e0a46ff8cf3c4cd9812e35fb48d0c95e4e | 449d555969bfd7befe906877abab098c6e63a0e8 | /2912/CH8/EX8.3/Ex8_3.sce | b4ddf7d60926ffbe1f09b4ee01798d4b2f9949a4 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 368 | sce | Ex8_3.sce | //chapter 8
//example 8.3
//Calculate relative permeability of a ferromagentic material
//page 236
clear;
clc;
//given
H=220; // in A/m (magnetic field intensity)
I=3300; // in A/m (intensity of magnetisation)
//calculate
mu_r=1+(I/H); // calculation of relative permeability
printf('\nThe relative permeability of a ferromagentic material is %.f',mu_r);
|
c7fb1d265f8e68d5ae555755cfe7f442c4d12281 | 449d555969bfd7befe906877abab098c6e63a0e8 | /3673/CH16/EX16.a.8/Example_a_16_8.sce | 626a2caf0e211e416ab48756145dc47bf42d1ae5 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 342 | sce | Example_a_16_8.sce | //Example_a_16_8 page no:786
clc;
Zl=20
Z11=10;
Z22=10;
Z12=4;
Z21=4;
V1=20;
Vs=20;
Zl=20;
I1=V1/(Z11-((Z12*Z21)/(Zl+Z22)));
I2=-I1*Z21/(Zl+Z22);
V2=-I2*20;
Zin=V1/I1;
disp(I1,"the current I1 is (in A)");
disp(I2,"the current I2 is (in A)");
disp(V2,"the voltage V2 is (in V)");
disp(Zin,"the input impedence is (in ohm)");
|
1c2548581d073107e549945d3711821bc6019e48 | 449d555969bfd7befe906877abab098c6e63a0e8 | /2159/CH2/EX2.15/215.sce | 1d54179f04d763bca008c19d3ddf72387f283731 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 190 | sce | 215.sce | // problem 2.15
w=450000
y=5.5
w1=80*1000000
q=3
gm=(w*y)/(w1*tand(q))
p=12.5*1000
n=120
T=(p*60000)/(2*3.142*n)
z=T/(w1*gm)
theta=atand(z)
disp(theta,"angle of heel in degree")
|
35d4f755e0bf4f2edfa6526fc8b6ae8ac5a42cbe | 449d555969bfd7befe906877abab098c6e63a0e8 | /964/CH4/EX4.4/4_4.sce | 24d01cf3ff210061f08673b7616702c305701ee5 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 787 | sce | 4_4.sce | clc;
clear;
function y=f(x)
y=-0.1*(x^4)-0.15*(x^3)-0.5*(x^2)-0.25*(x)+1.2
endfunction
x=0.5;
h=input("Input h:")
x1=x-h;
x2=x+h;
//forward difference method
fdx1=(f(x2)-f(x))/h;//derivative at x
et1=abs((fdx1-derivative(f,x))/derivative(f,x))*100;
//backward difference method
fdx2=(f(x)-f(x1))/h;//derivative at x
et2=abs((fdx2-derivative(f,x))/derivative(f,x))*100;
//central difference method
fdx3=(f(x2)-f(x1))/(2*h);//derivative at x
et3=abs((fdx3-derivative(f,x))/derivative(f,x))*100;
disp(h,"For h=")
disp(et1,"and percent error=",fdx1,"Derivative at x by forward difference method=")
disp(et2,"and percent error=",fdx2,"Derivative at x by backward difference method=")
disp(et3,"and percent error=",fdx3,"Derivative at x by central difference method=") |
20346ce16c2f372abcc73a3bb0344f4b6c904649 | 449d555969bfd7befe906877abab098c6e63a0e8 | /389/CH6/EX6.1/Example6_1.sce | 515045c6bc1e069b31c29315211e5cd72d000f82 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 1,738 | sce | Example6_1.sce | clear;
clc;
// Illustration 6.1
// Page: 145
printf('Illustration 6.1 - Page: 145\n\n');
// solution
//****Data****//
// w = Gas flow rate per orifice
w = 0.055/50;// [kg/s]
L = 8*10^(-4);// [liquid flow rate, cubic m/s]
d = 0.003;// [diameter of the orifice,m]
viscocity_gas = 1.8*10^(-5);// [kg/m.s]
//******//
Re = 4*w/(%pi*d*viscocity_gas);
Dp = 0.0071*Re^(-0.05);// [m]
h = 3;// [height of vessel,m]
P_atm = 101.3;// [kN/square m]
Density_water = 1000;// [kg/cubic m]
g = 9.81;// [m/s^2]
Temp = 273+25;// [K]
P_orifice = P_atm+(h*Density_water*g/1000);// [kN/square m]
P_avg = P_atm+((h/2)*Density_water*g/1000);// [kN/square m]
Density_gas = (29/22.41)*(273/Temp)*(P_avg/P_atm);// [kg/cubic m]
D = 1;// [dia of vessel,m]
Area = (%pi*D^2)/4;// [square m]
Vg = 0.055/(Area*Density_gas);// [m/s]
Vl = L/Area;// [m/s]
sigma = 0.072;// [N/m]
// From fig. 6.2 (Pg 143)
abscissa = 0.0516;// [m/s]
Vg_by_Vs = 0.11;
Vs = Vg/Vg_by_Vs;// [m/s]
deff('[y] = f6(shi_g)','y = Vs-(Vg/shi_g)+(Vl/(1-shi_g))');
shi_g = fsolve(0.5,f6);
dp = ((Dp^3)*(P_orifice/P_avg))^(1/3);// [bubble diameter,m]
// From eqn. 6.9
a = 6*shi_g/dp;// [specific interfacial area,square m]
printf("The Specific Interfacial Area is %f square m/cubic m\n",a);
// For diffsion of Cl2 in H20
Dl = 1.44*10^(-9);// [square m/s]
viscocity_water = 8.937*10^(-4);// [kg/m.s]
Reg = dp*Vs*Density_water/viscocity_water;
Scl = viscocity_water/(Density_water*Dl);
// From Eqn.6.11
Shl = 2+(0.0187*(Reg^0.779)*(Scl^0.546)*(dp*(g^(1/3))/(Dl^(2/3)))^0.116);
// For dilute soln. of Cl2 in H20
c = 1000/18.02;// [kmol/cubic m]
Fl = (c*Dl*Shl)/dp;// [kmol/square m.s]
printf("Mass Transfer coeffecient is %f kmol/square m.s\n",Fl); |
a1b6a61342bdcb4d15e305d33e00acfa55879c86 | 449d555969bfd7befe906877abab098c6e63a0e8 | /2258/CH5/EX5.7/5_7.sce | ff2447db12feea6a605ae1a65cb45f4a622ebdc5 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 286 | sce | 5_7.sce | clc();
clear;
// To calculate the transition temperature
Hc=5*10^3 //critical magnetic field in amp/m
Ho=2*10^4; //critical field in amp/m
T=6; //temp in K
Tc=T/sqrt(1-(Hc/Ho));
printf("the transition temperature is %f K",Tc)
//answer in the book is wrong
|
35933d9cca4e59eb4ac1029f41e48a8d7e5f5a96 | 1bb72df9a084fe4f8c0ec39f778282eb52750801 | /test/SH10.prev.tst | baa2a1d233facdf7e109d4eda4ddb6621fdc6145 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | gfis/ramath | 498adfc7a6d353d4775b33020fdf992628e3fbff | b09b48639ddd4709ffb1c729e33f6a4b9ef676b5 | refs/heads/master | 2023-08-17T00:10:37.092379 | 2023-08-04T07:48:00 | 2023-08-04T07:48:00 | 30,116,803 | 2 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 107 | tst | SH10.prev.tst | expression: a^b^c
postfix1: ;a;b;c;^;^
rebuilt1: a^(b^c)
postfix2: ;a;b;c;^;^
rebuilt2: a^(b^c)
same
|
845997ccea62a63aa927bf33779afc90e61597c0 | 449d555969bfd7befe906877abab098c6e63a0e8 | /1217/CH6/EX6.3/Exa6_3.sce | c1bfffd128316c2ea02fbb617b6212df7360bbb9 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 471 | sce | Exa6_3.sce | // Exa 6.3
clc;
clear;
close;
// given data
fc=2;//in KHz
AF=2;//unitless
// let C=0.01 uF
C=0.01;//in uF
R=(1/(2*%pi*fc*1000*C*10^-6))/1000;//in Kohm
R=ceil(R);
// Bias compensation Rbc
//Rbc=R1*RF/(R1+RF) ohm
disp("Bias compensation :R=R1*RF/(R1+RF)=Rdash/2 ohm");
//Rdash=R1=RF=2*R;//in ohm
Rdash=2*R;//in ohm
R1=2*R;//in ohm
RF=2*R;//in ohm
R1=RF;//in kohm
disp("Component values are :");
disp(R1,"R1=RF in Kohm is ;");
disp(R,"R in Kohm is ;"); |
477e25d386bc91caebdaac4de0642bf0d0739918 | 449d555969bfd7befe906877abab098c6e63a0e8 | /1427/CH16/EX16.26/16_26.sce | 9356f100221386f95489c7f5cfc01ddf61e2d311 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 244 | sce | 16_26.sce | //ques-16.26
//Calculating values of rate constants
clc
K=0.1;//equilibrium constant
R_T=10^-5;//relaxation time (in s)
//R_T = 1/(ka+kb)
//K=ka/kb
ka=1/(11*10^-5);
kb=10*ka;
printf("The value of ka is %d /s and kb is %d /s.",ka,kb);
|
b4d2e8b7fde1784e4630828c745371e8179fe3f9 | a62e0da056102916ac0fe63d8475e3c4114f86b1 | /set5/s_Electrical_Machines_M._V._Despande_833.zip/Electrical_Machines_M._V._Despande_833/CH13/EX13.6/Ex13_6.sce | e5c86acf6bafcbac5f2ac4a61931923e350eef04 | [] | no_license | hohiroki/Scilab_TBC | cb11e171e47a6cf15dad6594726c14443b23d512 | 98e421ab71b2e8be0c70d67cca3ecb53eeef1df6 | refs/heads/master | 2021-01-18T02:07:29.200029 | 2016-04-29T07:01:39 | 2016-04-29T07:01:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 512 | sce | Ex13_6.sce | errcatch(-1,"stop");mode(2);//Caption:Find number of armature conductors in series per phase
//Exa:13.6
;
;
p=10//Number of poles
ph=3//Number of phases
n=600//Speed of alternator(in r.p.m)
sl=90//Number of slots
Vl=6600//Line voltage(in volts)
B=0.1//Flux per pole(in wb)
cs=160//Coil span(in degrees)
kb=0.9597//Distribution factor
kp=0.9848//Pitch factor
v_ph=Vl/sqrt(3)
f=(p*n)/120
m=sl/(p*ph)
T=2*v_ph/(4.44*kb*kp*B*f)
disp(T,'Number of armature conductors in series per phase=')
exit();
|
8cbc911089cbda9cb40aa1a16389cf56cf411539 | a62e0da056102916ac0fe63d8475e3c4114f86b1 | /set12/s_Integrated_Circuits_P._Raja_2582.zip/Integrated_Circuits_P._Raja_2582/CH6/EX6.7/Ex6_7.sce | c7233228ee714c77a2d6cc0dff8a10d4952d730a | [] | no_license | hohiroki/Scilab_TBC | cb11e171e47a6cf15dad6594726c14443b23d512 | 98e421ab71b2e8be0c70d67cca3ecb53eeef1df6 | refs/heads/master | 2021-01-18T02:07:29.200029 | 2016-04-29T07:01:39 | 2016-04-29T07:01:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 197 | sce | Ex6_7.sce | errcatch(-1,"stop");mode(2);//Ex 6.7
;;
format('v',4);
n=8;//no. of bits
E=0.2;//%//maximum gain error
Vref=5.1;//V
V11=(100-E)*Vref/100;//V
disp(V11,"Minimum output voltage(V)");
exit();
|
19691d331e33e290f965f043b6db0b842ffd5ff3 | 449d555969bfd7befe906877abab098c6e63a0e8 | /2207/CH11/EX5.b/ex_5_b.sce | e2ea95208c98382530a734c63904ba7afb295e70 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 422 | sce | ex_5_b.sce | // Example 5(b): power absorbed
clc;
clear;
close;
v=400;//V
po=15;//kW
nfx=1440;//rpm
f=50;//Hz
z2=0.4+%i*1.6;//ohm
p=4;//
x=120;//Hz
ns=((x*f)/p);//rpm
s=((ns-nfx)/ns);//slip
ns1=(x*x)/p;//rpm
nfl1=(1-s)*ns1;//rpm
disp(nfl1,"full load speed is ,(rpm)=")
sm=real(z2)/imag(z2);//slip
disp(sm,"slip is,=")
tfy=((po*10^3)/(2*%pi*(nfl1/60)));//N-m
a=sm;//
tm=((a^2+s^2)/(2*a*s))*tfy;//N-m
disp(tm,"maximum torque is,(N-m)=")
|
916f7012760d6fdcc16b184cb20c0d05b7c05be8 | 449d555969bfd7befe906877abab098c6e63a0e8 | /2234/CH1/EX1.9/ex1_9.sce | 6c01d9fde2fa787d05f7aabe85a24ed87ec95c3b | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 167 | sce | ex1_9.sce | clc;
n=400; //frequency in Hz
v=300; //velocity in m/sec
l=v/n; //calculating wavelength
disp(l,"Wavelength in m = "); //displaying result |
13e923d8397768062cf4f31fffa5649087261412 | 449d555969bfd7befe906877abab098c6e63a0e8 | /3760/CH6/EX6.5/Ex6_5.sce | c00fb80ec1be493afbea83c72c7a5ad8f68eb64b | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 1,045 | sce | Ex6_5.sce | clc;
P=4;
N=1440;
f=50;
r2=0.2;
x2=1;
E2=120;
//mistake in Te_fl
//for part a
disp('For part a');
Ns=(120*f)/P;
I2_st=120/(sqrt((r2*r2)+(x2*x2)));
Rpf=(r2)/(sqrt((r2*r2)+(x2*x2)));
Ws=(2*3.14*Ns)/60;
Te_st=(3/Ws)*(I2_st)*(I2_st)*(r2/1);
s_fl=(Ns-N)/Ns;
I2_fl=(s_fl*E2)/(sqrt(r2*r2+(s_fl*x2*s_fl*x2)));
Rpf_fl=(r2)/(sqrt(r2*r2+(s_fl*x2*s_fl*x2)));
Te_fl=((3)*(I2_fl)*(I2_fl)*(r2))/(Ws*s_fl);
RATIOst_fl=I2_st/I2_fl;
RATIOtst_tfl=Te_st/Te_fl;
mprintf('At starting \n the rotor current is %f amp \n Rotor power factor is %f \n Torque is %f rad/sec\n',I2_st,Rpf,Te_st);
mprintf('At full load \n the rotor current is %f amp \n Rotor power factor is %f \n Torque is %f rad/sec\n',I2_fl,Rpf_fl,Te_fl);
//for part b
disp('For part b');
r2_n=r2+1;
I2_stn=E2/(sqrt((r2_n*r2_n)+(x2*x2)));
Rpf_stn=(r2_n)/(sqrt(((r2_n)*(r2_n))+((x2)*(x2))));
Te_stn=(3/Ws)*(I2_stn)*(I2_stn)*(r2_n/1);
mprintf('At starting \n the rotor current is %f amp \n Rotor power factor is %f \n Torque is %f rad/sec\n',I2_stn,Rpf_stn,Te_stn);
|
92208bb0f91ecb4ad97fe3a793320a23342237c5 | a62e0da056102916ac0fe63d8475e3c4114f86b1 | /set7/s_Electronic_Instrumentation_And_Measurements_D._A._Bell_182.zip/Electronic_Instrumentation_And_Measurements_D._A._Bell_182/CH9/EX9.5/example9_5.sce | 439acf8023af241b1d8431bbae49fad9b7db9ad9 | [] | no_license | hohiroki/Scilab_TBC | cb11e171e47a6cf15dad6594726c14443b23d512 | 98e421ab71b2e8be0c70d67cca3ecb53eeef1df6 | refs/heads/master | 2021-01-18T02:07:29.200029 | 2016-04-29T07:01:39 | 2016-04-29T07:01:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 323 | sce | example9_5.sce | errcatch(-1,"stop");mode(2);// to find the longest pulse width
// example 9-5 in page 261
;
//Given data
Ri=10e+6;// input resistance in ohm
Cc=0.1e-6;// coaxial cable capacitance in farad
//calculation
printf("pulse width=%.1f s",Ri*Cc/10);// here pulse width=tou/10 seconds
//result
//pulse width=0.1 s
exit();
|
fa26d2c26d1d33839145b4b38f461af9e0c9c3b6 | 449d555969bfd7befe906877abab098c6e63a0e8 | /1658/CH34/EX34.20/Ex34_20.sce | 6ba0960fd27c2b858f624c61b9afab685d26d7e2 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 101 | sce | Ex34_20.sce | clc;
R1=220;
R2=1500;
Vo=1.25*(1+(R2/R1));
disp('V',Vo*1,"Vo=");//answer given in book is wrong
|
e8b0a470d533e578cf47463814fbbd4a92d78e65 | 449d555969bfd7befe906877abab098c6e63a0e8 | /2300/CH13/EX13.16.1/Ex13_1.sce | e42f8cd8f050e7af32180d6f13bf3dd502422eea | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 604 | sce | Ex13_1.sce | //scilab 5.4.1
//Windows 7 operating system
//chapter 13 Field-Effect Transistors
clc
clear
ND=2*10^21//ND=donor concentration in m^-3 of an n-channel silicon JFET
e=1.6*10^-19//e=charge of an electron
E=12*8.854*10^-12//E=permittivity of the material where 12=dielectric constant of silicon(given)
a=(4*10^-6)/2//2*a=channel width in metres and 2*a=4*10^-6
Vp=(e*ND*(a^2))/(2*E)
format("v",5)
disp("V",Vp,"The pinch-off voltage is =")
VGS=-2//VGS=gate source voltage
//Vp=VDsat-VGS where VDsat=saturation voltage
VDsat=Vp+VGS
format("v",5)
disp("V",VDsat,"The saturation voltage is =")
|
ecba98cb3cc6a233240eb20ab195fe42a29e393f | 6a7b4e7f7cf3a38abe4d239fc8b61f0a543f500a | /diferenciales.sce | 760689f330a905bbe257c811eb125aacf20925f9 | [] | no_license | luvitale/calculo-numerico | 43459bc3db413f953e2f2a6f6bc196cc078ea406 | 28a04ff20f019e4ae80818372be412bffa894573 | refs/heads/master | 2020-03-18T12:46:12.456590 | 2018-07-07T03:46:08 | 2018-07-07T03:46:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 1,688 | sce | diferenciales.sce | function T = euler(t, y, f, h, N)
T = [t y]
for i = 1 : N
y = y + f(t, y) * h
t = t + h
T = [T; t y]
end
endfunction
function T = taylor2(t, y, N, h, f, df)
T = [t y]
for i = 1 : N
y = y + h * (f(t, y) + 0.5 * df(t, y) * h)
t = t + h
T = [T; t y]
end
endfunction
function T = rungeKutta2(t, y, h, f, N)
T = [t y]
for i = 1 : N
k1 = f(t, y) * h
t = t + h
k2 = f(t, y - k1) * h
y = y + (k1 + k2) / 2
T = [T; t y]
end
endfunction
function T = rungeKutta4(t, y, h, f, N)
T = [t y]
for i = 1 : N
k1 = f(t, y) * h
k2 = f(t + h/2, y + k1/2) * h
k3 = f(t + h/2, y + k2/2) * h
t = t + h
k4 = f(t, y + k3)
y = y + (k1 + 2 * (k2 + k3) + k4) / 6
T = [T; t y]
end
endfunction
function X1 = jacobi(X, A, B, M, N)
for i = 1 : M
for j = 1 : N
S = 0
for k = 1 : j - 1
S = S + A(j, k) * X(k)
end
for k = j + 1 : N
S = S + A(j, k) * X(k)
end
X1(j) = (B(j) - S) / A(j, j)
end
end
endfunction
function X = seidel(X, A, B, M, N)
for i = 1 : M
for j = 1 : N
S = 0
for k = 1 : j - 1
S = S + A(j, k) * X(k)
end
for k = j + 1 : N
S = S + A(j, k) * X(k)
end
X(j) = (B(j) - S) / A(j, j)
end
end
endfunction
function N = cantidadDeIteraciones(t0, tf, h)
N = (tf - t0) / h
endfunction
function h = cantidadDePasos(t0, tf, N)
h = (tf - t0) / N
endfunction
|
ce54e3544236d5e115093a6432674cd1841d291f | d963a50c09b7380dd7b1b97cd9997e9bd17ea8f3 | /r37/packages/sparse/sparse.tst | 5b73c26d34bd09bb651465a8a2ef5c8c86ea32ee | [
"BSD-3-Clause"
] | permissive | reduce-algebra/reduce-historical | 8220e211b116e0e01ff1a38f51917cac9db6069f | e014152729c4d62bb1ce4f5c311a027042a5495a | refs/heads/master | 2023-04-10T22:54:00.796596 | 2021-04-16T08:52:19 | 2021-04-16T08:52:19 | 343,245,204 | 7 | 1 | NOASSERTION | 2021-04-16T08:53:31 | 2021-03-01T00:15:22 | TeX | UTF-8 | Scilab | false | false | 5,485 | tst | sparse.tst | % Test file for Sparse Matrices and the Linear Algebra Package for
% Sparse Matrices.
% Author: Stephen Scowcroft. Date: June 1995.
% Firstly, the matrices need to be created.
% This is the standard way to create a sparse matrix.
% Create a sparse matrix.
sparse mat1(5,5);
%Fill the sparse matrix with data
mat1(1,1):=2;
mat1(2,2):=4;
mat1(3,3):=6;
mat1(4,4):=8;
mat1(5,5):=10;
sparse mat4(5,5);
mat4(1,1):=x;
mat4(2,2):=x;
mat4(3,3):=x;
mat4(4,4):=x;
mat4(5,5):=x;
% A small function to automatically fill a sparse matrix with data.
procedure makematsp(nam,row);
begin;
sparse nam(row,row);
for i := 1:row do <<nam(i,i):=i>>
end;
clear mat2;
makematsp(mat2,100);
% Matrices created in the standard Matrix way.
zz1:=mat((1,2),(3,4));
zz2:=mat((x,x),(x,x));
zz3:=mat((i+1,i+2,i+3),(4,5,2),(1,i,0));
% I have taken advantage of the Linear Algebra Package (Matt Rebbeck)
% in order to create some Sparse Matrices.
mat3:=diagonal(zz1,zz1,zz1);
mat5:=band_matrix({1,3,1},100)$
mat6:=diagonal(zz3,zz3);
mat7:=band_matrix({a,b,c},4);
% These are then "translated" into the Sparse operator using the
% function transmat.
% This is a destructive function in the sense that the matrices are no
% longer of type 'matrix but are now 'sparse.
transmat mat3;
transmat mat5;
transmat mat6;
transmat mat7;
poly := x^7+x^5+4*x^4+5*x^3+12;
poly1 := x^2+x*y^3+x*y*z^3+y*x+2+y*3;
% Firstly some basic matrix operations.
% These are the same as the present matrix package
mat1^-1;
mat4^-1;
mat2 + mat5$
mat2 - mat5$
mat1-mat1;
mat4 + mat1;
mat4 * mat1;
2*mat1 + (3*mat4 + mat1);
% It is also possible to combine both 'matrix and 'sparse type matrices
% in these operations.
pp:=band_matrix({1,3,1},100)$
mat5*pp;
mat5^2$
det(mat1);
det(mat4);
trace(mat1);
trace(mat4);
rank(mat1);
rank mat5;
tp(mat3);
spmateigen(mat3,eta);
% Next, tests for the Linear Algebra Package for Sparse Matrices.
%Basic matrix manipulations.
spadd_columns(mat1,1,2,5*y);
spadd_rows(mat1,1,2,x);
spadd_to_columns(mat1,3,1000);
spadd_to_columns(mat5,{1,2,3},y)$
spadd_to_rows(mat1,2,1000);
spadd_to_rows(mat5,{1,2,3},x)$
spaugment_columns(mat3,2);
spaugment_columns(mat1,{1,2,5});
spstack_rows(mat1,3);
spstack_rows(mat1,{1,3,5});
spchar_poly(mat1,x);
spcol_dim(mat2);
sprow_dim(mat1);
spcopy_into(mat7,mat1,2,2);
spcopy_into(mat7,mat1,5,5);
spcopy_into(zz1,mat1,1,1);
spdiagonal(3);
% spdiagonal can take both a list of arguments or just the arguments.
spdiagonal({mat2,mat5})$
spdiagonal(mat2,mat5)$
% spdiagonal can also take a mixture of 'sparse and 'matrix types.
spdiagonal(zz1,mat4,zz1);
spextend(mat1,3,2,x);
spfind_companion(mat5,x);
spget_columns(mat1,1);
spget_columns(mat1,{1,2});
spget_rows(mat1,3);
spget_rows(mat1,{1,3});
sphermitian_tp(mat6);
% matrix_augment and matrix_stack can take both a list of arguments
% or just the arguments.
spmatrix_augment({mat1,mat1});
spmatrix_augment(mat5,mat2,mat5)$
spmatrix_stack(mat2,mat2)$
spminor(mat1,2,3);
spmult_columns(mat1,3,y);
spmult_columns(mat2,{2,3,4},100)$
spmult_rows(mat2,2,x);
spmult_rows(mat1,{1,3,5},10);
sppivot(mat3,3,3);
sprows_pivot(mat3,1,1,{2,4});
spremove_columns(mat1,3);
spremove_columns(mat3,{2,3,4});
spremove_rows(mat1,2);
spremove_rows(mat2,{1,3})$
spremove_rows(mat1,{1,2,3,4,5});
spswap_cols(mat1,2,4);
spswap_rows(mat5,1,2)$
spswap_entries(mat1,{1,1},{5,5});
% Constructors - functions that create matrices.
spband_matrix(x,500)$
spband_matrix({x,y,z},6000)$
spblock_matrix(1,2,{mat1,mat1});
spblock_matrix(2,3,{mat3,mat6,mat3,mat6,mat3,mat6});
spchar_matrix(mat3,x);
cfmat := spcoeff_matrix({y+4*+-5*w=10,y-z=20,y+4+3*z,w+x+50});
first cfmat * second cfmat;
third cfmat;
spcompanion(poly,x);
sphessian(poly1,{w,x,y,z});
spjacobian({x^4,x*y^2,x*y*z^3},{w,x,y,z});
spjordan_block(x,500)$
spmake_identity(1000)$
on rounded; % makes output easier to read.
ch := spcholesky(mat1);
tp first ch - second ch;
tmp := first ch * second ch;
tmp - mat1;
off rounded;
% The gram schmidt functions takes a list of vectors.
% These vectors are matrices of type 'sparse with column dimension 1.
%Create the "vectors".
sparse a(4,1);
sparse b(4,1);
sparse c(4,1);
sparse d(4,1);
%Fill the "vectors" with data.
a(1,1):=1;
b(1,1):=1;
b(2,1):=1;
c(1,1):=1;
c(2,1):=1;
c(3,1):=1;
d(1,1):=1;
d(2,1):=1;
d(3,1):=1;
d(4,1):=1;
spgram_schmidt({{a},{b},{c},{d}});
on rounded; % again, makes large quotients a bit more readable.
% The algorithm used for splu_decom sometimes swaps the rows of the
% input matrix so that (given matrix A, splu_decom(A) = {L,U,vec}),
% we find L*U does not equal A but a row equivalent of it. The call
% spconvert(A,vec) will return this row equivalent
% (ie: L*U = convert(A,vec)).
lu := splu_decom(mat5)$
tmp := first lu * second lu$
tmp1 := spconvert(mat5,third lu);
tmp - tmp1;
% and the complex case..
on complex;
lu1 := splu_decom(mat6);
mat6;
tmp := first lu1 * second lu1;
tmp1 := spconvert(mat6,third lu1);
tmp - tmp1;
off complex;
mat3inv := sppseudo_inverse(mat3);
mat3 * mat3inv;
% Predicates.
matrixp(mat1);
matrixp(poly);
squarep(mat2);
squarep(mat3);
symmetricp(mat1);
symmetricp(mat3);
sparsematp(mat1);
sparsematp(poly);
off rounded;
end;
|
a97fc4cc5f46940379e2351873a96d35b2dad8c5 | adad792a303b401b6e5f683f5ffed0dce8bb89cb | /Newtonian.sce | 4be99ab5ead565e66e74b1f9a4d7e6aeefce60e6 | [
"MIT"
] | permissive | RDxR10/Numerical-Analysis | db114772f1a915e96d364a2cdb5c92e868da2640 | 10325dd514aa6ae9180dca7ae3a04f7deda5ca56 | refs/heads/master | 2020-09-11T18:51:42.948671 | 2019-11-24T16:01:44 | 2019-11-24T16:01:44 | 222,158,105 | 0 | 0 | null | 2019-11-19T17:10:11 | 2019-11-16T20:53:58 | Scilab | UTF-8 | Scilab | false | false | 678 | sce | Newtonian.sce | clear;
n=input("Enter the number of data points: ");
for i=1:n
x(i)=input("Enter x:");
y(i)=input("Enter y:");
end
h=x(2)-x(1);//interval
//Calculation of first order differences
for i=1:n-1
dy(i,1)=y(i+1)-y(i);
printf("First difference: %d\n",dy(i,1));
end
//Calculation of second order differences
for j=2:n-1
for i=1:n-j
dy(i,j)=dy(i+1,j-1)-dy(i,j-1);
printf("%d Difference: %d\n",j,dy(i,j));
end
end
//p value
p=(%s-x(1))/h;
disp(p);
//apply to formula
yval=y(1);
pnxt=p;
disp("Main Result");
for i=1:n-1
nxterm=pnxt*dy(1,i)/factorial(i);
yval=yval+nxterm;
pnxt=pnxt*(p-i);
end
disp(yval);
|
7002129b30a65d967b26712daebc61cbbf1f3401 | e8dbcf469ba8a31d6926ba791ebc5dcccd50282b | /Scripts/DML/Consultas/Test/consulta_por_ocupacion.tst | cca17243f793e4db1cc6c3da67c3b28b95e5c870 | [] | no_license | bryanjimenezchacon/bryanjimenezchacon.github.io | 5f2a0f1dbfbc584a65dece48f98b1c13d755512f | 7062d1860934808265c05491007c83f69da1112a | refs/heads/master | 2021-01-23T17:20:11.542585 | 2015-10-10T05:52:52 | 2015-10-10T05:52:52 | 41,244,377 | 2 | 0 | null | 2015-08-26T15:46:04 | 2015-08-23T09:52:06 | JavaScript | UTF-8 | Scilab | false | false | 242 | tst | consulta_por_ocupacion.tst | PL/SQL Developer Test script 3.0
5
begin
-- Call the procedure
personas_por_ocupacion(pocupacion => :pocupacion,
p_recordset => :p_recordset);
end;
2
pocupacion
1
Mante. electromec.
5
p_recordset
1
<Cursor>
116
0
|
f041753de7663bd4978640241569b9ae9dcaed40 | 1489f5f3f467ff75c3223c5c1defb60ccb55df3d | /tests/test_cache_1_b.tst | e03fa114fc538f3fb2ed7d19b7da7ab78308c5ff | [
"MIT"
] | permissive | ciyam/ciyam | 8e078673340b43f04e7b0d6ac81740b6cf3d78d0 | 935df95387fb140487d2e0053fabf612b0d3f9e2 | refs/heads/master | 2023-08-31T11:03:25.835641 | 2023-08-31T04:31:22 | 2023-08-31T04:31:22 | 3,124,021 | 18 | 16 | null | 2017-01-28T16:22:57 | 2012-01-07T10:55:14 | C++ | UTF-8 | Scilab | false | false | 890 | tst | test_cache_1_b.tst | item #0
item #1
item #2
item #3
item #4
item #5
item #6
item #7
item #8
item #9
item #10
item #11
item #12
item #13
item #14
item #15
item #16
item #17
item #18
item #19
item #20
item #21
item #22
item #23
item #24
item #25
item #26
item #27
item #28
item #29
item #30
item #31
item #32
item #33
item #34
item #35
item #36
item #37
item #38
item #39
item #40
item #41
item #42
item #43
item #44
item #45
item #46
item #47
item #48
item #49
item #50
item #51
item #52
item #53
item #54
item #55
item #56
item #57
item #58
item #59
item #60
item #61
item #62
item #63
item #64
item #65
item #66
item #67
item #68
item #69
item #70
item #71
item #72
item #73
item #74
item #75
item #76
item #77
item #78
item #79
item #80
item #81
item #82
item #83
item #84
item #85
item #86
item #87
item #88
item #89
item #90
item #91
item #92
item #93
item #94
item #95
item #96
item #97
item #98
item #99
|
85038da8aefcd96f0f7bea25cd451579b88d58ea | 449d555969bfd7befe906877abab098c6e63a0e8 | /374/CH6/EX6.9/69.sci | a851b15c88359a2adfc973f1c5c604ec1ef5dbf9 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 217 | sci | 69.sci | //chapter 6 example 9//
clc
clear
//electron transit time=tf,bandwidth=Bm,photoconductive gain=G,//
tf=8*(10^-12);//in seconds//
G=60;
Bm=(1/(2*%pi*tf*G))*(10^-8);
printf("\n maximum 3dB bandwidth=%f MHz\n",Bm) |
477018abf2f5a27f0a8c58c01b2087f52384b47a | ad617742f184bf6d4cceb3e9c99232d8bd52b862 | /tests/tape.tst | dad3600f927e2de9809651b2fb69ba3c1ab89bad | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive",
"BSD-2-Clause"
] | permissive | 9track/hyperion | d621343e7eea27c45db49c7c284dd1680491c82c | 9ceed2cc7261820eef01c55dac9b9a6ae47636b2 | refs/heads/master | 2022-09-15T12:19:09.059528 | 2020-05-28T03:05:29 | 2020-05-28T03:05:29 | 268,044,749 | 3 | 1 | NOASSERTION | 2020-05-30T09:03:56 | 2020-05-30T09:03:55 | null | UTF-8 | Scilab | false | false | 504 | tst | tape.tst |
*Testcase Tape Data Chaining
# Prepare test environment
mainsize 1
numcpu 1
sysclear
archlvl z/Arch
detach 580
attach 580 3490 "$(testpath)/tape.aws"
loadcore "$(testpath)/tape.core"
## t+ # (trace instructions)
t+580 # (trace device CCWs)
# Run the test...
runtest 0.25 # (plenty of time)
# Clean up afterwards
detach 580 # (no longer needed)
*Compare
r 800.8
*Want "SCSW fields" 00001008 0C403000
*Done
|
f92a5dce2ea4577bdc0efe96eb2537a9608997c7 | 3c47dba28e5d43bda9b77dca3b741855c25d4802 | /microdaq/examples/pwm_zvsfb/build.sce | 9865c538e9956da230611b32dd70ac3d2b9d7147 | [
"BSD-3-Clause"
] | permissive | microdaq/Scilab | 78dd3b4a891e39ec20ebc4e9b77572fd12c90947 | ce0baa6e6a1b56347c2fda5583fb1ccdb120afaf | refs/heads/master | 2021-09-29T11:55:21.963637 | 2019-10-18T09:47:29 | 2019-10-18T09:47:29 | 35,049,912 | 6 | 3 | BSD-3-Clause | 2019-10-18T09:47:30 | 2015-05-04T17:48:48 | Scilab | UTF-8 | Scilab | false | false | 867 | sce | build.sce | // Create new PWM block
b = mdaqBlock();
b.name = "ZVSFB";
b.param_name = ["PWM period"; "Default duty"]
b.param_size = [ 1 1 ];
b.param_def_val(1) = 1000;
b.param_def_val(2) = 50;
b.in = [4 1 1 1 1 1];
b.out = [];
mdaqBlockAdd(b)
copyfile(pathconvert(mdaqToolboxPath() + "examples/pwm_zvsfb/user_blocks/", %F), pathconvert(mdaqToolboxPath() + "/macros/user_blocks", %f));
copyfile(pathconvert(mdaqToolboxPath() + "examples/pwm_zvsfb/userlib/", %F), pathconvert(mdaqToolboxPath() + "/src/c/userlib/", %F));
deletefile(mdaqToolboxPath() + "/macros/user_blocks/mdaq_zvsfb.bin");
deletefile(mdaqToolboxPath() + "/macros/user_blocks/mdaq_zvsfb_sim.bin");
deletefile(mdaqToolboxPath() + "/src/c/userlib/mdaq_pwm_zvsfb.o");
deletefile(mdaqToolboxPath() + "/src/c/userlib/mdaq_zvsfb.o");
mdaqBlockBuild(%t, %f)
mprintf("Restart Scilab to use new Xcos block");
|
df35145cf1fbb974e0fd819a35d1c88df9f858d9 | 5f2ca8e18735204f5995ac7e44a6e301eb23ea0b | /scripts/controls/nz/lin_vs_nonlin_comparison.sce | 243e992f8e8ea3dfa42c6ddb4fd9c7c256b08858 | [] | no_license | Jettanakorn/mcflight | 4e7d4e20976e8f3621bf13fec2a8b522ecfc49a9 | e6579a11e10c5e9ae9ee558f464a6b88e1ae7a26 | refs/heads/master | 2023-03-17T10:49:28.906700 | 2019-10-30T20:20:58 | 2019-10-30T20:20:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 2,215 | sce | lin_vs_nonlin_comparison.sce | /*
* Checking accelerometer postion and NMP zero in load factor response
*/
clear
exec('eqm/eqm_body.sci');
exec('eqm/params_f16.sci');
exec('eqm/stability_deriv.sci');
exec('eqm/stability_deriv_body.sci');
params = load_f16();
exec('controls/nz/trim_v502_alt0_xcg35_level.sce');
disp('Building state-space...');
controls_trim = controls;
X0_lin_body = X0_body([
1 //u_ftps
3 //w_ftps
5 //theta_rad
8 //q_rps
]);
U0 = [ controls_trim.throttle
controls_trim.elev_deg];
rad2deg = 180/%pi;
/* Initializing state in body axis */
X0_body = X0;
X0_body(1) = params.VT_ftps*cos(X0(2))*cos(X0(3));
X0_body(2) = params.VT_ftps*sin(X0(3));
X0_body(3) = params.VT_ftps*sin(X0(2))*cos(X0(3));
controls_trim = controls;
function y = elev_step(t)
if(t<0.5) then
y = controls_trim.elev_deg;
elseif (t>=0.5 && t<=0.53)
y = controls_trim.elev_deg - 1/0.03*(t-0.5);
else
y = controls_trim.elev_deg-1;
end
endfunction
function xd = f16_model(t,X)
[xd] = eqm(t, X, controls, params);
endfunction
function xd = f16_model_body(t,X)
[xd] = eqm_body(t, X, controls, params);
endfunction
t = 0:0.001:3;
controls.elev_deg = elev_step;
y_body = ode(X0_body, t(1), t, f16_model_body);
ss_body = syslin("c", A_body, B_body, C_body, D_body);
disp('Simulating linear model...');
t = 0:0.001:3;
function u = elev_step_lin(t)
u = elev_step(t) - controls_trim.elev_deg;
endfunction
[y_lin_body,x_lin_body] = csim(elev_step_lin, t, ss_body(:,2));
disp('Comparing body and stability axis non-linear simulations');
f2 = scf(2);xgrid;xlabel('time(s)');ylabel('elevator (deg)');
title('Elevator input')
plot(t, elev_step);
f3 = scf(3);xgrid;xlabel('time(s)');ylabel('theta(deg)');
title('Theta linear x non-linear')
plot(t, y_body(5,:)*rad2deg, t, (x_lin_body(3,:) + X0_body(5))*rad2deg); // theta plot
legend('Non-linear','Linear');
f4 = scf(4);xgrid;xlabel('time(s)');ylabel('pitch rate(deg/s)');
title('Pitch rate linear x non-linear')
plot(t, y_body(8,:)*rad2deg, t, (x_lin_body(4,:) + X0_body(8))*rad2deg); // pitch rate plot
legend('Non-linear','Linear');
|
098dc401233b0c8cdb1239d5496dfc27c68e2ca1 | bc0a6b4d5e326bd35c72bec024b555ed91a1c543 | /plane2.sce | 0f79555b411de53ec628e3a69e396c5edaf037c9 | [] | no_license | askmrsinh/SEM1_AM | 0c9e7b4a51caa1321d1203cf9060e454b685e0ee | 31da57ba40d0741b370dd3c789a1dfec5c99bdea | refs/heads/master | 2021-09-28T03:09:18.743057 | 2016-08-18T15:01:52 | 2016-08-18T15:01:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 109 | sce | plane2.sce | //z=3 & z=-3 (PLANE)
deff('z=f1(x,y)','z=3');
fplot3d(x,y,f1)
deff('z=f2(x,y)','z=-3');
fplot3d(x,y,f2)
|
031d63abfdfdf22602a511c30ce6fda1fdb402dd | 449d555969bfd7befe906877abab098c6e63a0e8 | /1946/CH7/EX7.2/Ex_7_2.sce | afc5ed31039e81a09d02ba42eba4965ea502c506 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 406 | sce | Ex_7_2.sce | // Example 7.2;//power radiated by LED
clc;
clear;
close;
e=1.6*10^-19;//Electronic charge
ht=6.62*10^-34;//plank Constt
C=3*10^8;//sPPED OF LIGHT IN M/S
h=670*10^-9;//wavelength in meter
i=50;//injected current in milli ampere
nint=0.03;//inernal quantume efficiency
Pint= (nint*((ht*C*i*10^-3)/(e*h)))*10^2;//internal power level in milli watt
disp(Pint,"internal power level in milli watt")
|
b0a3a81adaf279435f682a8d8d5b52a540567862 | ca0ea3139875f786caa2df8ef9ada885b326dd6f | /scilab/trabalho1.sce | a4129063b769a160a175af919d4a1b4320c0d63e | [] | no_license | hitokey/exemplo-machine-learning | f0186a4e7acced7de16af6c96f3337129159225b | 2635ef2c88765b58267691a45a4b53f8d7207f2d | refs/heads/master | 2023-03-13T15:43:34.970552 | 2021-03-06T07:57:25 | 2021-03-06T07:57:25 | 289,837,645 | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 2,422 | sce | trabalho1.sce | // Aluno: Pedro Fernandes
// Hebb rules algorithms. Logic Bipolar.
// 17/08/2020
clc; // clean comand line
clear; // remove variable
// Input Table
s = [ 1 1
-1 1
1 -1
-1 -1];
// Output
t = [[-1 -1 -1 -1] // bits 0000
[-1 -1 -1 1] // bits 0001
[-1 -1 1 -1] // bits 0010
[-1 -1 1 1] // bits 0011
[-1 1 -1 -1] // bits 0100
[-1 1 -1 1] // bits 0101
[-1 1 1 -1] // bits 0110
[-1 1 1 1] // bits 0111
[ 1 -1 -1 -1] // bits 1000
[ 1 -1 -1 1] // bits 1001
[ 1 -1 1 -1] // bits 1010
[ 1 -1 1 1] // bits 1011
[ 1 1 -1 -1] // bits 1100
[ 1 1 -1 1] // bits 1101
[ 1 1 1 -1] // bits 1110
[ 1 1 1 1]] // bits 1111
// train
// initial prices
results = [];
bl = [];
liniar =0
for bit=1:16
wb = [0,0]; // resetando valores pesos w1 e w2
b = 0;// resetando valores unitario valor
bn = 0; // resetando valores
wb = [0,0]; // resetando valores
for inp=1:4
x(inp,:)=s(inp,:); //get linha de sources
y=t(bit,inp); // atribuindo valors de sainda a y
wn(1)=wb(1)+x(inp,1)*y; // calculando pesos input 1
wn(2)=wb(2)+x(inp,2)*y; // calculando pesos input 2
bn = b + y; // atribuindo no valor a base
wb = wn; // novo valore pesos base
b = bn; // atualizando valor de base
end
bl = lstcat(bl,bn); //amazenado os valores da entrada base
results=lstcat(results,wn); // amazenando os pesos
end
// Testando Resultados
for bit=2:17
wx = results(bit); // get valores dos pesos para um das target
bx = bl(bit); // get base valor para um dos target
mprintf('\nTarget binary(%d): Pesos: w1=%d w2=%d\n--------------\n',bit-2,wx(1),wx(2));
for inp = 1:4
yl = wx(1)*x(inp,1)+wx(2)*x(inp,2)+bx; // calculando y
if yl >= liniar // verificado y com linear
y = 1;
else
y = -1;
end
// print resultado formatado
if x(inp,1) == -1
mprintf('%d',x(inp,1));
else
mprintf(' %d',x(inp,1));
end
if x(inp,2) == -1
mprintf('&%d',x(inp,2));
else
mprintf('& %d',x(inp,2));
end
if y == -1
mprintf('&%d\\\\\n',y);
else
mprintf('& %d\\\\\n',y);
end
end
end
|
d2a005820c74b67476dcb6052a2f4c8d40d5b273 | f2d773b00b1387882aee366ee149118d8ef67b07 | /start.sci | 08adc31dbb3bfe6b90f44d6889025fea9c9cb627 | [] | no_license | eduartheinen/pso-tsp | c1689f9fa9b03bf14e1523cc14acc708499729c2 | 39309bede47a8d39b803ec12b8bc9cbce1edeb0f | refs/heads/master | 2021-01-11T08:42:20.788981 | 2016-10-07T23:21:57 | 2016-10-07T23:21:57 | 69,510,304 | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 363 | sci | start.sci | clear
clc
exec("objectivefn.sci")
exec("pathrelinking.sci")
exec("removecrossings.sci")
exec("pso-tsp.sci")
//main
//data = fscanfMat("ch130.tsp"); //best possible solution 6110
data = fscanfMat("eil51.tsp"); //best possible solution 426
particles = 20
iterations = 50
x = zeros(1, 10)
for i=1:10
x(i) = run(data, particles, iterations)
end
disp(stdev(x))
|
3510a8695184879b459ec336ba49e06d43211b8a | 449d555969bfd7befe906877abab098c6e63a0e8 | /405/CH4/EX4.1/4_1.sce | 5f09e48d1525de5e73d995df61bf404d68cb772e | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 1,051 | sce | 4_1.sce | clear;
clc;
printf("\t\t\tExample Number 4.1\n\n\n");
// steel ball cooling in air
// illustration4.1
// solution
h = 10;// [W/square meter per degree celsius] convectional heat transfer coefficient
k = 35;// [W/m per degree celsius] heat transfer coefficient
c = 460;// [kJ/kg]
r = 0.05/2;// [m] diameter of ball
Tb = 450;// [degree celsius] ball temperature
Te = 100;// [degree celsius] environment temperature
A = 4*%pi*r^(2);
V = 4*%pi*r^(3)/3;
// We anticipate that the lumped capacity method will apply because of the low value of h and high value of k
// we check by using equation (4-6)
K = h*(V/A)/k;
// since the value of K is less than 0.1 so we will use equation (4-5)
T = 150;// [degree celsius] attained temperature by the ball
rho = 7800;// [kg/cubic meter] density of the ball
a = (h*A)/(rho*c*V);
t = log((T-Te)/(Tb-Te))/(-a);// [s] time required to attain the temperature of 150 degree celsius
printf("time required to attain the temperature of 150 by degree celsius by the ball is %f h",t/3600);
|
e6dea67c9eef5075e1622ff9aae5b262784a158e | 449d555969bfd7befe906877abab098c6e63a0e8 | /3012/CH11/EX11.3/Ex11_3.sce | 119bc0631c33889c67016aba74d38c82535f9ea5 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 1,913 | sce | Ex11_3.sce | // Given:-
// Part(a)
v = 0.4646 // specific volume in in m^3/kg
M = 18.02 // molar mass of water in kg/kmol
// At the specified state, the temperature is 513 K and the specific volume on a molar basis is
vbar = v*M // in m^3/kmol
// From Table A-24
a = 142.59 // (m^3/kmol)^2 * K^.5
b = 0.0211 // in m^3/kmol
Rbar = 8314.0 // universal gas constant in N.m/kmol.K
T = 513.0 // in kelvin
delpbydelT = (Rbar/(vbar-b) + a/(2*vbar*(vbar+b)*T**1.5)*10**5)/10**3 // in kj/(m^3*K)
// By The Maxwell relation
delsbydelv = delpbydelT
// Result
printf( ' The value of delpbydelT in kj/(m^3*K) is: %.2f',delpbydelT);
// Part(b)
// A value for (dels/delv)T can be estimated using a graphical approach with steam table data, as follows: At 240C, Table A-4 provides the values for specific entropy s and specific volume v tabulated below
T = 240.0 // in degree celcius
// At p =1, 1.5, 3, 5, 7, 10 bar respectively
y = [7.994, 7.805, 7.477, 7.230, 7.064, 6.882]
x = [2.359, 1.570, 0.781, 0.4646, 0.3292, 0.2275]
plot(x,y)
xlabel("Specific volume")
ylabel("Specific entropy")
// The pressure at the desired state is 5 bar.The corresponding slope is
delsbydelv = 1 // in kj/m^3.K
printf( ' From the data of the table,delsbydelv = %.2f',delsbydelv);
|
047476af55b2b434bc0ac989badffe66a3f00f51 | 449d555969bfd7befe906877abab098c6e63a0e8 | /1826/CH10/EX10.16/ex10_16.sce | 35568d206bfeecd4bbfa7827bdd49324ef5359db | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 302 | sce | ex10_16.sce | // Example 10.16, page no-278
clear
clc
e=1.6*10^-19//C
m=9.1*10^-31//kg
mm=0.31*m//kg
h=6.626*10^-34
k=1.38*10^-23
eg=1.1*e
T=300//K
ni=2*(2*%pi*mm*k*T/(h^(2)))^(1.5)
ni=ni*%e^(-eg/(2*k*T))
printf("The intrinsic concentration of Si at %d K is %.4f * 10^15 electrons per m^3",T,ni*10^-15)
|
82a4d9e1f8c45db2a450a1129e17b3ccf9b78dcd | 449d555969bfd7befe906877abab098c6e63a0e8 | /1958/CH3/EX3.5/Chapter3_example5.sce | ee20f9015493af149ca1cfdc9a7f0227a3c83868 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 360 | sce | Chapter3_example5.sce | clc
clear
//Input data
m=(9.1*10^-31)//Mass of the electron in kg
v=(3*10^8)//Velocity of light in m/s
c=(1.6*10^-19)//Charge of the electron in coloumbs
//Calculations
Re=(m*v^2)/(c*10^6)//Rest energy in MeV
E=(Re/sqrt(1-0.9^2))//Total energy in MeV
//Output
printf('Rest energy of the electron is %3.3f MeV \n Total energy is %3.4f MeV',Re,E)
|
88becb13732bd6812550b2cacc72e6b0a546939b | 717ddeb7e700373742c617a95e25a2376565112c | /2474/CH2/EX2.12/Ch02Ex12.sce | d8ed7b34431850c0a5281ecacd66ae0306f58099 | [] | no_license | appucrossroads/Scilab-TBC-Uploads | b7ce9a8665d6253926fa8cc0989cda3c0db8e63d | 1d1c6f68fe7afb15ea12fd38492ec171491f8ce7 | refs/heads/master | 2021-01-22T04:15:15.512674 | 2017-09-19T11:51:56 | 2017-09-19T11:51:56 | 92,444,732 | 0 | 0 | null | 2017-05-25T21:09:20 | 2017-05-25T21:09:19 | null | UTF-8 | Scilab | false | false | 548 | sce | Ch02Ex12.sce | // Scilab code Ex2.12: Pg.90 (2008)
clc; clear;
E_1 = 5; // Energy of first photon, MeV
E_2 = 2; // Energy of second photon, MeV
p_1 = 5; // Momentum of first photon, MeV/c
p_2 = -2; // Momentum of second photon, MeV/c
E = E_1 + E_2; // Total energy of the system, MeV
p = p_1 + p_2; // Total momentum of the system, MeV/c
E = sqrt((E^2)-(p^2)); // Rest energy of the system, MeV
printf("\nThe rest energy of the system of photons = %3.1f MeV",E);
// Result
// The rest energy of the system of photons = 6.3 MeV
|
6b359db4546d2816669d0cae81ceeda086b91e64 | 449d555969bfd7befe906877abab098c6e63a0e8 | /671/CH3/EX3.26/3_26.sce | 632d4ef645aa69dd5eec957d086e174f46099b34 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 72 | sce | 3_26.sce | //at t=0-
iL=4
v=0
disp(v,iL)
//at t=0+
iL=4
v=-4*20
disp(v,iL) |
b2ebf85724b5165ca3080a44a1878346e141e67e | e9d5f5cf984c905c31f197577d633705e835780a | /data_reconciliation/linear/scilab/P10/P10.sce | 7f626e390eb27e0de3458be7119d8ca17d6723a0 | [] | no_license | faiz-hub/dr-ged-benchmarks | 1ad57a69ed90fe7595c006efdc262d703e22d6c0 | 98b250db9e9f09d42b3413551ce7a346dd99400c | refs/heads/master | 2021-05-18T23:12:18.631904 | 2020-03-30T21:12:16 | 2020-03-30T21:12:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 4,547 | sce | P10.sce | // Data Reconciliation Benchmark Problems From Lietrature Review
// Author: Edson Cordeiro do Valle
// Contact - edsoncv@{gmail.com}{vrtech.com.br}
// Skype: edson.cv
//Martins, Márcio A.F., Carolina A. Amaro, Leonardo S. Souza, Ricardo A. Kalid, and Asher Kiperstok. 2010.
//New objective function for data reconciliation in water balance from industrial processes.
//Journal of Cleaner Production (March): 1-6. doi:10.1016/j.jclepro.2010.03.014. http://linkinghub.elsevier.com/retrieve/pii/S0959652610001149.
//Bibtex Citation
//@article{Martins2010,
//author = {Martins, M\'{a}rcio A.F. and Amaro, Carolina A. and Souza, Leonardo S. and Kalid, Ricardo A. and Kiperstok, Asher},
//doi = {10.1016/j.jclepro.2010.03.014},
//file = {::},
//issn = {09596526},
//journal = {Journal of Cleaner Production},
//month = mar,
//pages = {1--6},
//title = {{New objective function for data reconciliation in water balance from industrial processes}},
//url = {http://linkinghub.elsevier.com/retrieve/pii/S0959652610001149},
//year = {2010}
//}
// 13 Streams
// 8 Equipments
clear xm var jac nc nv i1 i2 nnzeros sparse_dg sparse_dh lower upper var_lin_type constr_lin_type constr_lhs constr_rhs
// the measures
xm =[28.06
3.06
5.28
8.89
11.39
3.89
4.17
2.78
5.83
4.44
3.89
15.0
13.33
];
//the variance proposed by the original author with some modifications
var = [0.075618
0.002498
0.029749
0.021084
0.138439
0.016148
0.018556
0.002062
0.009067
0.005259
0.004037
0.021609
0.017065
];
//the variance proposed by this work
//var = ones(13,1);
// gross error
gerror = zeros(length(xm),1);
// to setup gross errors, select the stream and magnitude as the line bellow
//gerror(2) = 9*sqrt(var(2));
xm = xm + gerror;
//The jacobian of the constraints
// 1 2 3 4 5 6 7 8 9 10 11 12 13
jac = [ 1 -1 -1 -1 -1 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 -1 0 0 0 0 0
0 0 1 0 0 0 0 0 -1 0 0 0 0
0 0 0 1 0 -1 -1 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 1 -1 0
0 0 0 0 0 1 0 0 0 -1 0 0 0
0 0 0 0 0 0 1 0 0 0 -1 0 0
0 0 0 0 0 0 0 1 1 1 0 0 -1];
// 1 2 3 4 5 6 7 8 9 10 11 12 13
//observability/redundancy tests
umeas_P10 = [];
[red_P10, just_measured_P10, observ_P10, non_obs_P10, spec_cand_P10] = qrlinclass(jac,umeas_P10)
// reconcile with all measured. To reconcile with only redundant variables, uncomment the "red" assignments
measured_P10 = setdiff([1:length(xm)], umeas_P10);
red = measured_P10;//
// to reconcile with all variables, comment the line above and uncomment bellow
//red = [1:length(xm)];
// to run robust reconciliation,, one must choose between the folowing objective functions to set up the functions path and function parameters:
//WLS = 0
// Absolute sum of squares = 1
//Cauchy = 2
//Contamined Normal = 3
//Fair = 4
//Hampel = 5
//Logistic = 6
//Lorenztian = 7
//Quasi Weighted = 8
// run the configuration functions with the desired objective function type
obj_function_type = 0;
exec ../functions/setup_DR.sce
// to run robust reconciliation, it is also necessary to choose the function to return the problem structure
if obj_function_type > 0 then
[nc_eq, n_non_lin_eq, nv, nnzjac_ineq, nnzjac_eq, nnz_hess, sparse_dg, sparse_dh, lower, upper, var_lin_type, constr_lin_type, constr_lhs, constr_rhs] = robust_structure(jac, 0, xm, objfun, res_eq, res_ineq);
else
// for WLS, only the line bellow must be choosen and comment the 3 lines above
[nc, nv, i1, i2, nnzeros, sparse_dg, sparse_dh, lower, upper, var_lin_type, constr_lin_type, constr_lhs, constr_rhs] = wls_structure(jac);
end
params = init_param();
// We use the given Hessian
params = add_param(params,"hessian_approximation","exact");
params = add_param(params,"derivative_test","second-order");
params = add_param(params,"tol",1e-8);
params = add_param(params,"acceptable_tol",1e-8);
params = add_param(params,"mu_strategy","adaptive");
params = add_param(params,"journal_level",5);
[x_sol, f_sol, extra] = ipopt(xm, objfun, gradf, confun, dg, sparse_dg, dh, sparse_dh, var_lin_type, constr_lin_type, constr_rhs, constr_lhs, lower, upper, params);
mprintf("\n\nSolution: , x\n");
for i = 1 : nv
mprintf("x[%d] = %e\n", i, x_sol(i));
end
mprintf("\n\nObjective value at optimal point\n");
mprintf("f(x*) = %e\n", f_sol);
|
970adb974427cbeabc86332226d389a65eb4f8fd | 449d555969bfd7befe906877abab098c6e63a0e8 | /3831/CH10/EX10.4/Ex10_4.sce | 912c9395dc368fdf3830455ad2b5b7fb57a5775e | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 989 | sce | Ex10_4.sce | // Example 10_4
clc;funcprot(0);
// Given data
m=1.00;// kg
T_0=20.0;// °C
p_0=0.101;// MPa
T_s=130.0+273;// K
x_1=0.00;// The quality of steam at state 1
T_1=120.0;// °C
x_2=0.500;// The quality of steam at state 1
// Calculation
// State 1
x_1=0;// The quality of steam at state 1
T_1=120.0+273;// K
v_f=0.001060;// m^3/kg
v_1=v_f;// m^3/kg
u_f=503.5;// kJ/kg
u_1=u_f;// kJ/kg
s_f=1.5280;// kJ/kg.K
s_1=s_f;// kJ/kg.K
// State 2
x_2=0.500;// The quality of steam at state 2
p_sat=198.5;// kN/m^2
p_1=p_sat;// kN/m^2
p_2=p_1;// kN/m^2
v_2=0.44648;// m^3/kg
u_2=1516.4;// kJ/kg
s_2=4.3292;// kJ/kg.K
// Ground state
T_0=20.0+273;// K
p_0=0.101;// MPa
a_2minusa_1=(u_2-u_1)+(p_0*10^3*(v_2-v_1))-(T_0*(s_2-s_1));// kJ/kg
W_12=m*p_2*(v_2-v_1);// kJ
Q_12=(m*(u_2-u_1))+W_12;// kJ
I_12=((1-(T_0/T_s))*Q_12)-W_12+(p_0*10^3*(v_2-v_1));// kJ
printf("\nThe irreversibility of the process,I_12=%2.1f kJ",I_12)
// The answer provided in the textbook is wrong
|
9766aba278e44c5fb38d31208dd62664af7afde5 | 448b934390596180e5965efadbcbe8e13809ab8c | /macros/pkgGetPaths.sci | 5cfb87c3ab101d1c6837e8676f5dd83efc68a177 | [] | no_license | pirpyn/pkg-scilab | 3834d8b5e5e7cbb71e2d2cff14ea763d32259bf0 | b3ac0d499c9b446d02159f29068616fcf2a57f56 | refs/heads/master | 2021-01-19T17:36:20.707736 | 2017-12-11T21:31:23 | 2017-12-11T21:31:23 | 101,072,162 | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 326 | sci | pkgGetPaths.sci | function pkgGetPaths(mask,titl,multifiles)
if ~exists('mask') then
mask = ['*.sce','*.txt','*.xml','*.sci']
elseif mask =='%dir'
paths = uigetdir(home,titl)
else
paths = matrix(uigetfile(mask,home,titl,multifiles),-1,1)
end
tag = gcbo.user_data
ui = pkgFindObj(tag)
ui.String = paths
endfunction
|
420e630de3a87f582dfb6c5c4e19b56514f5b96e | 81a7e7bbbdadf675a70f5ac7dd91aabafd748348 | /Assignment 3/projectionLS.sce | a791f9a7175e56c1dd1577263e58ae7c704d6cda | [] | no_license | SreejeshSaya/LinearAlgrabra-SciLab | 089cef88d83e9bea68b3df0c20386957c7b7dcb0 | 0b0c22e2775b998701d2f8e44aa178d9dbc43d19 | refs/heads/master | 2020-12-29T20:38:17.084259 | 2020-04-06T06:50:12 | 2020-04-06T06:50:12 | 238,723,714 | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 561 | sce | projectionLS.sce | clear;
//
//A=[1, 0; 0, 1; 1, 1]
//User input
rows = 3;
cols = 2;
A = zeros(rows,cols);
disp("Inputs to all matrices to be sequential left to right, top to bottom");
disp("Inputs to A begin");
for i = 1:rows
for j = 1:cols
A(i,j) = input("value for A:")
end
end
//b=[1; 1; 0]
//User input
b = zeros(rows,1);
disp("Inputs for B begin");
for i = 1:rows
b(i) = input("Value for B:")
end
disp(A, 'A=');
disp(b, 'b=')
x=(A'*A)\(A'*b);
disp(x, 'x=');
C=x(1,1);
D=x(2,1);
disp(C, 'C=');
disp(D, 'D=');
disp('The line of best fit is b=C+Dt');
|
09024bbb930012697f8f5b51afe2e1e80589d423 | 8712fac5701f1aea100763dd8e3c1e4a06470df1 | /FFT_exemplo.sci | 6cf37a32b9ff267e91dca4c5b0dd3826a1f87aa6 | [] | no_license | paula-an/FourierScilab | a47404673d957a098b988444aec86c50b1fc96f4 | 32782dfe8904107c9a4c707f683f931570b195a1 | refs/heads/master | 2022-12-04T06:37:40.792025 | 2020-08-10T22:05:42 | 2020-08-10T22:05:42 | 285,903,782 | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 1,144 | sci | FFT_exemplo.sci | clc // Limpa o console
clear // Apaga as variáveis do "navegador de variáveis"
xdel(winsid()) // Apaga as janelas gráficas abertas
//
// Taxa de amostragem
ts = 1000 // [Hz]
//
// Tempo discreto
t = 0:1/ts:0.1 // [s]
//
// Número de amostras
N = length(t)
//
// Frequências associadas:
// A resposta da FFT é simétrica deve-se exibir
// apenas a primeira metade dos pontos (N/2)
freq_vec = ts*(0:(N/2))/N // [Hz]
freq_n = length(freq_vec) // Número de frequências a serem exibidas
//
// f(t)
ft = 10*sin(2*%pi*50*t)+5*sin(2*%pi*200*t)
//
// Aplicando a transformada de Fourier no sinal f(t)
Fw = fft(ft)
// Aplicando a função abs() (módulo) e eliminando metade do sinal
Fw = abs(Fw(1:freq_n))
// Corrigindo a amplitude do sinal no domínio da frequência
Fw = 2*Fw/N;
//
// Resultados
// Sinal no domínio do tempo - f(t)
scf()
plot(t, ft, 'LineWidth', 2)
xlabel('Tempo (s)')
ylabel('Amplitude')
xgrid()
// Sinal no domínio da frequência - F(w)
scf()
plot(freq_vec, Fw, 'LineWidth', 2)
xlabel('Frequência (Hz)')
ylabel('Amplitude')
mtlb_axis([0 500 0 max(Fw)])
xgrid()
|
09b2985524514222f38322850bca015422c002cb | 8217f7986187902617ad1bf89cb789618a90dd0a | /source/2.4.1/macros/percent/%hm_conj.sci | f3b1fc5a57a164bd7cf87a81ed67625048dedb9e | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | clg55/Scilab-Workbench | 4ebc01d2daea5026ad07fbfc53e16d4b29179502 | 9f8fd29c7f2a98100fa9aed8b58f6768d24a1875 | refs/heads/master | 2023-05-31T04:06:22.931111 | 2022-09-13T14:41:51 | 2022-09-13T14:41:51 | 258,270,193 | 0 | 1 | null | null | null | null | UTF-8 | Scilab | false | false | 78 | sci | %hm_conj.sci | function M=%hm_conj(M)
// Copyright INRIA
M('entries')=conj(M('entries'))
|
fc4e872c5d88680a20e33a752bad8add55ad369b | 449d555969bfd7befe906877abab098c6e63a0e8 | /1757/CH5/EX5.33/EX5_33.sce | 13c05590d8c1b02fc747987610ffb527826a99e1 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 694 | sce | EX5_33.sce | //Example5.33 // To find Slew rate and closed loop gain of an op-amp
clc;
clear;
close;
fu = 1*10^6 ; // Hz // unity gain bandwidth
fmax = 5*10^3 ; // KHz // full power bandwidth
F3db = 12*10^3 ; // Hz // small signal bandwidth
Vp = 10 ; // V // peak volt
// the full power bandwidth of an op-amp
// fmax=FPBW = (Slew rate/2*3.14*Vp);
Slewrate = 2*3.14*Vp*fmax;
Slewrate = Slewrate*(10^-6); // *10^-6 because Slewrate is V/u
disp('the Slew rate of an op-amp is = '+string(Slewrate)+' V/u sec ');
// // the 3-db frequency or small signal band width
//f3db = (f/ACL);
//the closed loop gain ACL
ACL = fu/F3db ;
disp('The closed loop gain ACL is = '+string(ACL)+' ');
|
b3730e87c6556507aca416b78303208a7c2f7ea5 | 449d555969bfd7befe906877abab098c6e63a0e8 | /2642/CH3/EX3.14/Ex3_14.sce | b585a9279d6ef160126d93e612d8c7873d612718 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 935 | sce | Ex3_14.sce | // FUNDAMENTALS OF ELECTICAL MACHINES
// M.A.SALAM
// NAROSA PUBLISHING HOUSE
// SECOND EDITION
// Chapter 3 : TRANSFORMER AND PER UNIT SYSTEM
// Example : 3.14
clc;clear; // clears the console and command history
// Given data
E_1 = 500 // secondary induced voltages in V
E_2 = 450 // secondary induced voltages in V
kVA_1 = 100 // kVA ratings of transformer
kVA_2 = 200 // kVA ratings of transformer
Z_1 = 0.05 // impedance of transformer
Z_2 = 0.08 // impedance of transformer
// caclulations
Z1 =Z_1*E_1/(kVA_1*10^3/E_1) // actual impedance of 1st transformer in ohm
Z2 = Z_2*E_2/(kVA_1*10^3/E_2) // actual impedance of 2nd transformer in ohm
Z = %i*(Z1+Z2)
I_c = (E_1-E_2)/(Z) // value of the circulating current
// display the result
disp("Example 3.14 solution");
printf(" \n Value of the circulating current \n I_c = %.3f<%.f A \n", abs(I_c),atand(imag(I_c),real(I_c)));
|
93e6d9f9376df40fc890575d79eea62801efba25 | 449d555969bfd7befe906877abab098c6e63a0e8 | /2015/CH4/EX4.3.a/4_3a.sce | 77d2b0c9f6af09a9c9fa9d3d3fbbd830a5d04224 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 467 | sce | 4_3a.sce | clc
//initialisation of variables
h1=2801 //kj/kg
h3=867.5 //kj/kg
h4=1087 //kj/kg
ieff=0.50 //isentropic efficiency of compression
wt=903.8 //kj/kg
feff=0.75 //furnace efficiency
ieeff=0.85//isentropic expansion efficiency
//CALCULATIONS
hx=((h4-h3)/0.5)+867.5
wr=hx-h3
atu=ieeff*wt
hs=h1-hx
nwo=atu-wr
eff=nwo/hs
oeff=eff*feff
wrt=nwo/atu
ssc=3600/nwo
hr=3600/oeff
//RESULTS
printf('steam and heat rates are %2fkg/kwh and %2fkj/kwh',ssc,hr)
|
7437189724261f29fdb1fdf7105469754615c485 | 449d555969bfd7befe906877abab098c6e63a0e8 | /2489/CH11/EX11.4/11_4.sce | 7de47462d3b1814169113285cc1c0bb39a8c2e62 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 220 | sce | 11_4.sce | clc
//Intitalisation of variables
clear
dH= 12300 //cal
T= 25 //C
dS= -60.1 //cal deg^-1 mole^-1
//CALCULATIONS
dF= dH-dS*(273+T)
//RESULTS
printf ('Standard free energy of formation = %.f cal mole^-1 ',dF-10)
|
e46cddc84bbe165de45a2035a2f0e1e6dbbb8a67 | 449d555969bfd7befe906877abab098c6e63a0e8 | /1859/CH7/EX7.29/exa_7_29.sce | 4c67ee0908872724b0c04009d4d78e05b6dab333 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 385 | sce | exa_7_29.sce | // Exa 7.29
clc;
clear;
close;
// Given data
f= 500;// in kHz
f=f*10^3;// in Hz
C=120;// in pF
C=C*10^-12;// in F
R= 5;// in ohm
r=0.02;// resistance used across the oscillatory circuit in ohm
omega= 2*%pi*f;// in radians/sec
Q_True= 1/(omega*C*R);
Q_indicated= 1/(omega*C*(R+r));
PerError= (Q_True-Q_indicated)*100/Q_True;// in %
disp(PerError,"Percentage Error is ")
|
48fa52176445cc372f3c0ea1aef91ed3c5eb255d | ca0ea3139875f786caa2df8ef9ada885b326dd6f | /scilab/trabalho3adaline.sce | 3e954ffad61b034221a1c7603db0d781e223e01e | [] | no_license | hitokey/exemplo-machine-learning | f0186a4e7acced7de16af6c96f3337129159225b | 2635ef2c88765b58267691a45a4b53f8d7207f2d | refs/heads/master | 2023-03-13T15:43:34.970552 | 2021-03-06T07:57:25 | 2021-03-06T07:57:25 | 289,837,645 | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 840 | sce | trabalho3adaline.sce | clc;
clear;
xx = [0.00 0.50 1.00 1.50 2.00 2.50 3.00 3.50 4.00 4.50 5.00]
yy = [2.26 3.80 4.43 5.91 6.18 7.26 8.15 9.14 10.87 11.58 12.55]
clf();
set(gca(),"auto_scale", "on");
set(gca(),"data_bounds", [-1,-1;7,14]);
title("Dados");
xlabel("X");
ylabel("Y");
dxa=gda();
dxa.y_location="origin";
dxa.x_location="origin";
plot(xx,yy,'bd');
wa = 0.5-rand(1,1,"uniform");
ba = 0.5-rand();
teta = 0;
alfa = 0.01;
nc=50;
cc=0;
mprintf("Train\n");
while cc<=nc
erroq=0;
cc=cc+1
for inp=1:11
yl=wa*xx(inp)+ba;
yc=yl;
erroq=erroq+(yy(inp)-yc)^2;
wn=wa+alfa*(yy(inp)-yc)*xx(inp);
bn=ba+alfa*(yy(inp)-yc);
wa=wn;
ba=bn;
end
end
mprintf("y=%fx+%f", wn, bn);
for abc=0:0.1:6
ord = abc*wn+bn;
plot(abc,ord,'g.');
end
|
21399705fd4bde87aed7c75871f254badd35ba4b | 449d555969bfd7befe906877abab098c6e63a0e8 | /2681/CH8/EX8.7/Ex8_7.sce | 461d24652390be50462d7784303b292099b68b1f | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 263 | sce | Ex8_7.sce | //minimum distance between two antennas
//given
clc
Da=5//metre
f=5d+9//hertz
v=3d+8//m/s
lemda=v/f//metre
r=2*(Da^2)/lemda//metre
r=round(r*100)/100///rounding off decimals
disp(r,'the minimum distance required between two antennas in metre')//metre
|
7e219f8692c72135b28f5e5b63a47c6161b3ed54 | 449d555969bfd7befe906877abab098c6e63a0e8 | /551/CH6/EX6.10/10.sce | a3628ee11c41a381c969715377fd68f81601baf8 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 437 | sce | 10.sce | clc
m_O2=1; //kg
m_H2=1; //kg
p=1*10^5; //Pa
T_O2=450; //K
T_H2=450; //K
T0=290; //K
R0=8.314;
M_O2=32;
M_H2=2;
R_O2=R0/M_O2;
v_O2=m_O2*R_O2*T_O2/p;
R_H2=R0/M_H2;
v_H2=m_H2*R_H2*T_H2/p;
v_f=v_O2 + v_H2; //total volume after mixing
dS_O2=R_O2*log(v_f/v_O2);
dS_H2=R_H2*log(v_f/v_H2);
dS_net=dS_O2 + dS_H2;
//Let E be the loss in availability
E=T0*dS_net;
disp("Loss in availability=")
disp(E)
disp("kJ") |
66f98e58a4d6424157795d7aeb3ed753061a2714 | 8217f7986187902617ad1bf89cb789618a90dd0a | /browsable_source/1.1/Unix/scilab-1.1/macros/auto/specfact.sci | 83856f4e6ee63c67195ef904ae02615a18cab71e | [
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | clg55/Scilab-Workbench | 4ebc01d2daea5026ad07fbfc53e16d4b29179502 | 9f8fd29c7f2a98100fa9aed8b58f6768d24a1875 | refs/heads/master | 2023-05-31T04:06:22.931111 | 2022-09-13T14:41:51 | 2022-09-13T14:41:51 | 258,270,193 | 0 | 1 | null | null | null | null | UTF-8 | Scilab | false | false | 108 | sci | specfact.sci | function [w0,l]=specfact(a,b,c,d)
r=d+d',w0=sqrt(d),
p=ricc(a-b/r*c,b/r*b',-c'/r*c,'cont')
l=w0\(c+b'*p)
|
7932c21ffdf13d15ece65ef9d11935e9dd8be31b | 449d555969bfd7befe906877abab098c6e63a0e8 | /2990/CH6/EX6.18/Ex6_18.sce | 922b88ee5620bbbce2974c9ff909e778a5c8c87d | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 211 | sce | Ex6_18.sce |
clc; funcprot(0);
// Initialization of Variable
B=741.0;//airbase in m
f=152.4;//focal length in mm
pa=94.32;//in mm
ha=325;//elevation in mm
//calculation
H=ha+B*f/pa;
disp(H,"height in m")
clear()
|
ad97d303c2a739770e187fac4d94838812c30a12 | 449d555969bfd7befe906877abab098c6e63a0e8 | /683/CH3/EX3.25/MS_25.sce | d1b506488384acaefcbfec08c8ead6d54eba3aed | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 336 | sce | MS_25.sce | // sum 3-25
clc;
clear;
P=2*10^6;
N=200;
w=2*%pi*N/60;
Tm=P/w;
W=5*10^3*9.81;
l=1800;
Mmax=W*l/4;
Tmax=1.8*Tm*10^3;
Me=(Mmax+sqrt(Mmax^2+Tmax^2))/2;
Te=sqrt(Mmax^2+Tmax^2);
sig=60;
Ts=40;
d1=(32*Me/(%pi*sig))^(1/3);
d2=(16*Te/(%pi*Ts))^(1/3);
// printing data in scilab o/p window
printf("d is %0.1f mm ",d2); |
bcdc6c41705b15a21b84e5867088137bd0565e7c | 3cbee2296fd6b54f80587eead83813d4c878e06a | /sci2blif/sci2blif_added_blocks/wta.sce | d40d26e2e8f93cc5abdeec3a999f5bf868512bae | [] | no_license | nikhil-soraba/rasp30 | 872afa4ad0820b8ca3ea4f232c4168193acbd854 | 936c6438de595f9ac30d5619a887419c5bae2b0f | refs/heads/master | 2021-01-12T15:19:09.899590 | 2016-10-31T03:23:48 | 2016-10-31T03:23:48 | 71,756,442 | 0 | 0 | null | 2016-10-24T05:58:57 | 2016-10-24T05:58:56 | null | UTF-8 | Scilab | false | false | 840 | sce | wta.sce | //***************************** WTA ************************************
if (blk_name.entries(bl) =='wta') then
addvmm = %t;
mputl("#WTA",fd_w);
for ss=1:scs_m.objs(bl).model.ipar(1)
mputl(".subckt wta in[0]=net"+string(blk(blk_objs(bl),2))+"_"+string(ss)+ " in[1]=net"+string(blk(blk_objs(bl),3))+"_"+string(ss)+" out[0]=net"+ string(blk(blk_objs(bl),2+numofip))+"_" + string(ss)+" #wta_fg =0",fd_w);
mputl(" ",fd_w);
plcvpr = %t;
//need a better way to handle the plcloc
if grep(plcloc,'10 1 0')>0 then
plcloc=[plcloc;'net'+string(blk(blk_objs(bl),2+numofip))+'_'+ string(ss),'10 '+string(ss+1)+' 0'];
else
plcloc=[plcloc;'net'+string(blk(blk_objs(bl),2+numofip))+'_'+ string(ss),'10 '+string(ss)+' 0'];
end
// disp(plcloc)
end
end
|
317858edae107c7e9fc2dc3b93627ee0a48e5681 | 449d555969bfd7befe906877abab098c6e63a0e8 | /28/CH9/EX9.8.a/ex9_8_1.sce | f939921b03a733629c1c0cd187899d2dd842026a | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 217 | sce | ex9_8_1.sce | // from the nyquist plot
N=-2; // no of encirclements
P=0; // given
Z=P-N
printf("Since Z=2 therefore two roots of the characteristic equation lies in the right half of s-plane,hence the system is unstable")
|
2ab33dc1394a7e46dbe0513cabf87ba1c799b2f7 | 449d555969bfd7befe906877abab098c6e63a0e8 | /1646/CH16/EX16.3/Ch16Ex3.sce | 84fa3a71ced5158fdb157b77e002400c312aba4c | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 682 | sce | Ch16Ex3.sce | // Scilab Code Ex16.3 : Page-821 (2011)
clc; clear;
p = 3; q = 4; r = %inf; // Coefficients of intercepts along three axes
p_inv = 1/p; // Reciprocate the first coefficient
q_inv = 1/q; // Reciprocate the second coefficient
r_inv = 1/r; // Reciprocate the third coefficient
mul_fact = double(lcm(int32([p,q]))); // Find l.c.m. of m,n and p
m1 = p_inv*mul_fact; // Clear the first fraction
m2 = q_inv*mul_fact; // Clear the second fraction
m3 = r_inv*mul_fact; // Clear the third fraction
printf("\nThe miller indices of the given planes are : (%d %d %d) ", m1,m2,m3);
// Result
// The miller indices of the given planes are : (4 3 0)
|
ca52807f88ddf935a48ca9ad1819abe5a567526f | 85796c94fc9059fcb09697ae3509fd9488d77aa8 | /initConfig.sci | 5d870c575da7a0f211be03cf1e58b40825c0210a | [] | no_license | MyCSDegree/snakenladder | 680d5cd7687da44a227c2b242765ab96e0b7534d | bedb901cbcede9ca3972514ec12686b33a9eaf85 | refs/heads/master | 2016-08-06T04:08:29.276575 | 2015-10-28T01:16:18 | 2015-10-28T01:16:18 | 42,781,425 | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 503 | sci | initConfig.sci | global p
global c
p = 0;
c = 0;
global p0
global c0
p0 = 0;
c0 = 0;
global sizesnake
global sizeladder
sizesnake = 10;
sizeladder = 4;
green = 3;
red = 5;
global c_player
global c_ai
c_player = green;
c_ai = red;
global s_player
global s_ai
s_player = 'o'
s_ai = 'x'
// sleeptime in ms
global sleeptime
sleeptime = 100
// linspace duration
global lin_space
lin_space = 50
// safety flag
global sf_continue
sf_snake = %F;
sf_ladder = %F;
// finally clear console and screen
clf;
clc;
|
c4c75fea608b3e25074a4f4fe185a84742b394e6 | b6b875fb04ec6df2c0fb0d28f36962fa9aebb2bf | /TD3/TD3 - 2/Log.sci | 9a9f1e48d9cc3e4a19f0a38baf4a2a548efe4ec6 | [] | no_license | MFrizzy/Modelisation | 51794b2edf421f9d2206cb73972d8d8d7b1e9759 | 0ca819afbcbe00f58f3bbaa8fc97164ae2c1d3cb | refs/heads/master | 2021-08-29T12:02:20.042037 | 2017-12-13T22:39:21 | 2017-12-13T22:39:21 | 106,943,303 | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 450 | sci | Log.sci | clear
clf
// variables du modèles
r = 1 ; A = 0.5 ; K = 2.5 ; B=0.5 ; C=0.3 ;
x = linspace(0, 2.5, 301);
function f = predation(x) // fonction qui calcule la vitesse d'accroissement
f =r * x .* (1 - x / K) - B * (x.^2 ./ (x.^2 + C^2)) // opération vectorielle
endfunction
plot2d(x, predation(x), style = 2); // Tracé de la vitesse d'accroissement
// Définition des paramètres d'affichages
a=gca();
a.x_location = "origin";
a.grid=[5,5];
|
b33b674af8bf5b13be32e49b5674c9157c30b6cc | f42e0a9f61003756d40b8c09ebfe5dd926081407 | /TP4/newton.sci | 84b2fc6fa4955ffd0525ca94d9429f1acc121ccd | [] | no_license | BenFradet/MT09 | 04fe085afaef9f8c8d419a3824c633adae0c007a | d37451249f2df09932777e2fd64d43462e3d6931 | refs/heads/master | 2020-04-14T02:47:55.441807 | 2014-12-22T17:34:50 | 2014-12-22T17:34:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 481 | sci | newton.sci | function[x, k] = newton(foncjac, tol, Kmax, x0)
if Kmax - floor(Kmax) ~= 0 | Kmax < 0
error('Kmax must be an int');
end
if tol < 0 | abs(tol) < %eps
error('wrong tol');
end
for k = 1:Kmax
[f, J] = foncjac(x0);
correction = J\-f;
x = x0 + correction;
if (norm(x - x0) / norm(x)) < tol
return x;
else
x0 = x;
end
end
error('didnt converge');
endfunction
|
bd7480b186674bb207872562c0aa3dd3b5ea67d2 | 449d555969bfd7befe906877abab098c6e63a0e8 | /964/CH18/EX18.6/18_6.sce | 42f75071db6c0eed1ca297e2adfb4b5973bb7acd | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 357 | sce | 18_6.sce | //clc()
x = 2;
x0 = 1;
m = 0;
x1 = 4;
n = 1.386294;
x2 = 6;
p = 1.791759;
f1 = (x - x1)*m/((x0 - x)) + (x- x0) * n/(x1 - x0);
disp(f1,"first order polynomial f1(2) = ")
f2 = (x - x1)*(x - x2)*m/((x0 - x1)*(x0 - x2)) + (x - x0)*(x - x2)*n/((x1-x0)*(x1-x2)) + (x - x0)*(x - x1)*p/((x2 - x0)*(x2 - x1));
disp(f2,"second order polynomial f2(2) = ")
|
864515f12df652632cff6def7c0072058e8ac0ee | 29cfe7e83274e757dc406cdc2a855f7e76fdb698 | /scilab/ellipsesAxis.sci | 0ad365d69c8c4d7eea5765f8841f041ffaa5fe0f | [] | no_license | andreucm/essential_maths_roboticists | 2eb637afe3f46be6eb6c697eba7ada1d9406f482 | 95530267db0890be1e76778062d8eafd41d451dd | refs/heads/master | 2022-07-16T05:18:15.976563 | 2022-07-01T08:36:47 | 2022-07-01T08:36:47 | 47,470,143 | 1 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 2,255 | sci | ellipsesAxis.sci | //computes ellipses minor and major axis from 2D covariance matrix
function [axis] = ellipsesAxis(Cmat)
//ensure positive-definite matrix
Cchol = chol(Cmat);
CC = Cchol'*Cchol;
//compute evecs and evals
[RR,diagCC] = spec(CC);
eval1 = diagCC(1,1);
eval2 = diagCC(2,2);
evec1 = [RR(1,1);RR(2,1)];
evec2 = [RR(1,2);RR(2,2)];
//return first the biggest eval, then the smallest and finally the angle
if (eval1>eval2) then
axis = [eval1;eval2;atan(RR(2,1),RR(1,1))*180/%pi];
else
axis = [eval2;eval1;atan(RR(2,2),RR(1,2))*180/%pi];
end
endfunction
//trace_ellipse
//xc,yc is the center
//a main axis, the one which is rotates phi wrt the plot horizontal
//b second axis
function [] = draw_ellipses(xc, yc, a, b, phi)
step = 0.1;
t = 0:step:%pi/2;
X = a*cos(t);
Y = b*sin(t);
n = 4*size(X,'*');
XY1 = [X, -flipdim(X,2), -X, flipdim(X,2);...
Y, flipdim(Y,2), -Y, -flipdim(Y,2)];
XY = rotate(XY1, phi) + [xc*ones(1,n);yc*ones(1,n)];
xpoly(XY(1,:), XY(2,:));
endfunction
//draws ellipses in the current axis, given by the
//covariance matrix Cmat, and centered at point mu
function[] = draw_ellispes_from_cov(mu, Cmat, axes_h)
//ensure positive-definite matrix
Cchol = chol(Cmat);
CC = Cchol'*Cchol;
//compute eigenvalues
[RR,diagCC] = spec(CC);
eval1 = diagCC(1,1);
eval2 = diagCC(2,2);
//sort evals by value. Set major and minor axes, and orientation angle of the ellipses
if (eval1>eval2) then
axis = [eval1;eval2;atan(RR(2,1),RR(1,1))];
else
axis = [eval2;eval1;atan(RR(2,2),RR(1,2))];
end
//start drawing (compute all points)
step = 0.1; //Set drawing step
t = 0:step:%pi/2; //set drawing vector
eX = axis(1)*cos(t); //ellispes points (X component, a quarter)
eY = axis(2)*sin(t); //ellipses points (Y component, a quarter)
nn = 4*size(eX,'*'); //num of total points of the ellipses
eXY1 = [eX, -flipdim(eX,2), -eX, flipdim(eX,2); eY, flipdim(eY,2), -eY, -flipdim(eY,2)];
eXY = rotate(eXY1, axis(3)) + [mu(1)*ones(1,nn);mu(2)*ones(1,nn)];
sca(axes_h); //Set current axes
xpoly(eXY(1,:), eXY(2,:));
endfunction
|
f9c074c49d4a7e867de4206ffe8cd476b5d31f0c | 449d555969bfd7befe906877abab098c6e63a0e8 | /2165/CH6/EX6.10/6_10.sce | 1635413295604c403c657137b7e9b9c92af68606 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 491 | sce | 6_10.sce | clc
//initialisation of variables
d=0.15//lb
p=20//lb/in^2
p1=100//lb/iN62
t=200//degree C
f=10//percent
Pt=0.5457*p1//lb/in^2
x1=0.996//in
x2=0.952//in
h=29//C.H.U/lb
h1=65//C.H.U/lb
v=7.73//ft^3
v1=20.12//ft^3
T=0.364//in
T1=0.465//in
v2=sqrt(2*32.2*1400*h)//ft/sec
v3=sqrt(2*32.2*1400*h1)//ft/sec
//CALCULATIONS
V1=d*v*x1//ft^3
V2=d*v1*x2//ft^3
A1=(V1/v2)*144//in^2
A2=(V2/v3)*144//in^2
//RESULTS
printf('the throat and exit diameters of the nozzle=% f in^2',A2)
|
94838f461de2172c63ad15172935cf9e4e6490ba | b6b875fb04ec6df2c0fb0d28f36962fa9aebb2bf | /TD1/beverton/bevertonC.sce | 6452dd436aca943cda84223e781d2b476d58b076 | [] | no_license | MFrizzy/Modelisation | 51794b2edf421f9d2206cb73972d8d8d7b1e9759 | 0ca819afbcbe00f58f3bbaa8fc97164ae2c1d3cb | refs/heads/master | 2021-08-29T12:02:20.042037 | 2017-12-13T22:39:21 | 2017-12-13T22:39:21 | 106,943,303 | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 235 | sce | bevertonC.sce | clear
clf
r=1.2;
Cvect = 0.02:0.01:0.11;
ndate = 0:30;
for i = 1:10
C=Cvect(i);
x(1) = 1;
for n = 1:30
x(n+1)=r*(x(n)/(C*x(n)+1));
end
plot2d(ndate, x, style = -1);
plot2d(ndate, x, style = i);
end
|
ea48ece9c44c6caa0ac75f1d877b3995ee273880 | 449d555969bfd7befe906877abab098c6e63a0e8 | /2951/CH6/EX6.6.A/additional_ex_6.sce | 85e6049ee5b5186b58ae93163ddc2c89ef1f9ec3 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 223 | sce | additional_ex_6.sce | clc;
clear;
F=16;// Power ratio in dB
k=1.38*10^(-23) ;// boltzman constant
T=290; //temperature in K
B=5; //Bandwidth in MHz
P=(F-1)*k*T*B*10^(6);
disp(" Amplifier Inout noise power (in watts) is");
disp(P);
|
b8bfe1cb17263df20118836cd9a9140436bbca18 | 449d555969bfd7befe906877abab098c6e63a0e8 | /761/CH14/EX14.3/14_3.sce | ad76fec37e0eb735422507060e8b4d5c29f3100e | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 313 | sce | 14_3.sce | clc;
//page no 463
//prob no. 14.3
//Cable with teflon dielectric er=2.1
er=2.1;c=3*10^8;//Velocity of light
//Determination of velocity factor
Vf=1/sqrt(er);
disp(Vf,'The value of velocity factor is');
//Determination of propagation velocity
Vp=Vf*c;
disp('m/s',Vp,'The value of propagation velo. is'); |
618ce42becf804731f4741513b4dbf6fb7e0ec5c | 449d555969bfd7befe906877abab098c6e63a0e8 | /1299/CH4/EX4.3/example4_3.sce | 4c06879509970b44583e57244b0868264369d40d | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 309 | sce | example4_3.sce | //Example 4.3
//for given matrix "A" proving eigen values of "A"="t^-1*A*T"
clear;clc;
xdel(winsid());
A=[0 1 0;0 0 1;-6 -11 -6]
P=bdiag(A) //eigen values of "A"
T=[1 1 1;-1 -2 -3; 1 4 9] //vandermode matrix
inv(T)
A1=inv(T)*A*T //diagonal canonical form of A
//thus "P=A1" is proved.
|
4dd2cbbfd54cda20dadf551f08fa9ef81a0a9790 | 449d555969bfd7befe906877abab098c6e63a0e8 | /1523/CH4/EX4.33/ex4_33.sce | 6b76d6219c98932d068cbb5f0d42124a16fc317a | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 453 | sce | ex4_33.sce | //AC Circuits : example 4.33 :pg(4.27)
Vm=177;
Im=14.14;
phi=30;
V=(Vm/sqrt(2));
I=(Im/sqrt(2));
pf=cosd(30);
P=(V*I*pf);
disp("v(t)=177sin(314t+10)");// value of 10 is in degrees
disp("i(t)=14.14sin(314t-20)");//value of 20 is in degrees
mprintf("\nCurrent i(t) lags behind voltage v(t) by 30degrees");
disp("phi=30degrees");
printf("Power factor pf=cos(30)=%.3f (lagging)",pf);
printf("\nPower consumed P=V*I*cos(phi)=%.1f W",P); |
706490d90d09a39229ac90803f50c6ba6e46accd | 449d555969bfd7befe906877abab098c6e63a0e8 | /1538/CH21/EX21.15/Ex21_15.sce | 47c5f2d0eddfc0cea39109a025eccf9c057eed36 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 374 | sce | Ex21_15.sce | //example-21.15
//page no-651
//given
//length of wire
l=250*10^-3 //m
//no of turns
N=400
//current
I=15 //A
//permeability in vaccum
mu0=1.2457*10^-6 //H/m
//relative permeability
mur=1
//magnetic field strength
H=N*I/l //AT/m
//flux density is
B=mu0*mur*H //Wb/m^2
printf ("the magnetic field strength is %f AT/m and flux density is %f Wb/m",H,B)
|
eed12a627ed8ef9bde921cce4db7acdadc0018a1 | 449d555969bfd7befe906877abab098c6e63a0e8 | /593/CH10/EX10.3/ex10_3.sce | ac4ffe33e21e3847f7b99220c26d9fc8fad89239 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 3,848 | sce | ex10_3.sce | clear;
//clc();
// Example 10.2
// Page: 262
printf("Example-8.2 Page no.-262\n\n");
//***Data***//
// The initial data for this example is same as that of example 10.2, i.e.
P = 800;//[psia] Bubble point pressure
x_e = 0.60;// Mole fraction of ethane in liquid phase
x_h = (1-x_e);// Mole fraction of n-heptane in the liquid phase
R = 0.08314;//( L*bar/(mol*K)) Universal gas constant
// Changing the pressure in bar
Pb = (800/14.7)*(1.01325);//[bar]
// In this problem we will denote ethane by 'e' and that to n-heptane by 'h'
// From table A.1 ( page 417 ) given in the book, critical temperatures of ethane and heptane are
T_c_e = 305.3;//[K]
T_c_h = 540.2;//[K]
// and critical pressures are
P_c_e = 48.72;//[bar]
P_c_h = 27.40;//[bar]
// also the accentric facors are
w_e = 0.1;
w_h = 0.35;
// Thus we have
P_r_e = Pb/P_c_e;
P_r_h = Pb/P_c_h;
// Now from equations (F.13) and (F.14) ( page 459 ) given in the book we have
// A_e = 0.42747 + ( 1 + (0.480 + 1.574*w_e - 0.17*w_e^(2))*( 1 - T_r_e^(0.5)))^(2)*(P_r_e/T_r_e^(2));
// A_h = 0.42747 + ( 1 + (0.480 + 1.574*w_h - 0.17*w_h^(2))*( 1 - T_r_h^(0.5)))^(2)*(P_r_h/T_r_h^(2));
// and
// B_e = 0.08664*(P_r_e/T_r_e);
// B_h = 0.08664*(P_r_h/T_r_h);
// We will take the help trial and error method both on Temperature and the vapor phase composition of ethane
// Let us assume the starting temperature 200 deg F. Changing this temperature in K
T = (200-32)*5/9 + 273.15;//[K]
err = 1;
while err > 10^(-4)
T_r_e = T/T_c_e;
T_r_h = T/T_c_h;
A_e = 0.42747*( 1 + (0.480 + 1.574*w_e - 0.17*w_e^(2))*( 1 - T_r_e^(0.5)))^(2)*(P_r_e/T_r_e^(2));
A_h = 0.42747*( 1 + (0.480 + 1.574*w_h - 0.17*w_h^(2))*( 1 - T_r_h^(0.5)))^(2)*(P_r_h/T_r_h^(2));
B_e = 0.08664*(P_r_e/T_r_e);
B_h = 0.08664*(P_r_h/T_r_h);
// Now we will take the starting value of vapor phase composition of ethane as
y_e = 0.9;
err1 = 1;
while err1 > 10^(-6)
// Now value of A_mix and B_mix for both liquid and vapor phase are calculated as
A_mix_l = (x_e*sqrt(A_e) + x_h*sqrt(A_h))^(2);// For liquid phase
A_mix_v = (y_e*sqrt(A_e) + (1 - y_e)*sqrt(A_h))^(2);// For vapor phase
B_mix_l = (x_e*B_e + x_h*B_h);// For liquid
B_mix_v = (y_e*B_e + (1 - y_e)*B_h);// For liquid
deff('[y]=f(z1)','y = z1^(3) - z1^(2) + z1*(A_mix_l - B_mix_l - B_mix_l^(2)) - A_mix_l*B_mix_l');
z_l = fsolve(0.2,f);
// and
deff('[y]=g(z2)','y = z2^(3) - z2^(2) + z2*(A_mix_v - B_mix_v - B_mix_v^(2)) - A_mix_v*B_mix_v');
z_v = fsolve(0.3,g);
// Now
phi_el = B_e/B_mix_l*( z_l - 1) - log(z_l - B_mix_l) - (A_mix_l/B_mix_l)*(2*sqrt(A_e/A_mix_l)-B_e/B_mix_l)*log(1-B_mix_l/z_l);
phi_hl = B_h/B_mix_l*( z_l - 1) - log(z_l - B_mix_l) - (A_mix_l/B_mix_l)*(2*sqrt(A_h/A_mix_l)-B_h/B_mix_l)*log(1-B_mix_l/z_l);
phi_ev = B_e/B_mix_v*( z_v - 1) - log(z_v - B_mix_v) - (A_mix_v/B_mix_v)*(2*sqrt(A_e/A_mix_v)-B_e/B_mix_v)*log(1-B_mix_v/z_v);
phi_hv = B_h/B_mix_v*( z_v - 1) - log(z_v - B_mix_v) - (A_mix_v/B_mix_v)*(2*sqrt(A_h/A_mix_v)-B_h/B_mix_v)*log(1-B_mix_v/z_v);
K_e = phi_el/phi_ev;
K_h = phi_hl/phi_hv;
y_e1 = K_e*x_e;
y_h1 = K_h*x_h;
err1 =abs((y_e1 - y_e));
y_e = y_e1;
end
err = abs((y_e1 + y_h1) -1);
T = T + 0.1;
end
// Changing the temperature in deg F, we have
Tf = ( T - 273.15)*9/5 + 32;//[F]
printf(" Bubble point of the given ethanol and n-heptane mixture at 800 psia is %f deg F\n",Tf);
printf(" Amount of ethanol in the vapour phase of the mixture at the given condition is %f \n",y_e1);
printf(" Amount of n-heptane in the vapour phase of the mixture at the given condition is %f ",y_h1);
|
fe5a89ba5180029c3a66d7c2c38bbcc273d3db28 | 67310b5d7500649b9d53cf62226ec2d23468413c | /tags/archive/TestCaseGenerator-Plugin-OpeningSequenceCoverage/trunk/tests/large-system-tests/inputs/jEdit/ground_truth/OpeningSequenceCoverage/length-1/max-150/t12.tst | 23148331453e5e0c026a15862dc2c5dbbd713c78 | [] | no_license | csnowleopard/guitar | e09cb77b2fe8b7e38d471be99b79eb7a66a5eb02 | 1fa5243fcf4de80286d26057db142b5b2357f614 | refs/heads/master | 2021-01-19T07:53:57.863136 | 2013-06-06T15:26:25 | 2013-06-06T15:26:25 | 10,353,457 | 1 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 661 | tst | t12.tst | <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TestCase>
<Step>
<EventId>e68</EventId>
<ReachingStep>false</ReachingStep>
</Step>
<Step>
<EventId>e63</EventId>
<ReachingStep>false</ReachingStep>
</Step>
<Step>
<EventId>e53</EventId>
<ReachingStep>false</ReachingStep>
</Step>
<Step>
<EventId>e79</EventId>
<ReachingStep>false</ReachingStep>
</Step>
<Step>
<EventId>e37</EventId>
<ReachingStep>false</ReachingStep>
</Step>
<Step>
<EventId>e43</EventId>
<ReachingStep>false</ReachingStep>
</Step>
</TestCase>
|
ee0985ca5f248d6b452f451b49bc503591f35dde | 449d555969bfd7befe906877abab098c6e63a0e8 | /2381/CH1/EX1.17/ex_17.sce | c13f58466f0f36f69cc5584835fff2bae981b5fa | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 538 | sce | ex_17.sce | //Example 17 // possible values and energy
clc;
clear;
close;
r1=2;//from graph
r2=4.5;//units from graph
disp("possible values of r are "+string(r1)+" units and "+string(r2)+" units")
osc=1-(-2.5);//units
disp("maximum energy of oscillations for r=2 units is "+string(osc)+" units ")
osc1=0.5-(-1);//units
disp("maximum energy of oscillations for r=4.5 units is "+string(osc1)+" units ")
t=1;//from graph
v=0;//from graph
e=t+v;//
disp(e,"total energy is,(unit)=")
disp("at infinity V = "+string(v)+" therefore T = "+string(t)+" unit ")
|
6ab29c624b75c0ba885610175136bd7e9c03bde9 | 449d555969bfd7befe906877abab098c6e63a0e8 | /2882/CH3/EX3.19/Ex3_19.sce | f5d51a8425a2ebe6e0c9fc9ff9886d3fca894d31 | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 651 | sce | Ex3_19.sce | //Tested on Windows 7 Ultimate 32-bit
//Chapter 3 Semiconductor Diodes and Miscellaneous Devices Pg no. 102
clear;
clc;
//Given Data
Vz=18;//zener breakdown voltage in volts
Izmax=60;//maximum safe current through diode in milli-amperes
R=150;//series resistance in ohms
Rl=1D3;//load resistance in ohms
//Solution
Vinmin=((Rl+R)/Rl)*Vz;//minimum value of input voltage
Iload=Vz/Rl*1000;//load current in milli-amperes
Imax=Izmax+Iload;//maximum current through battery in milli-amperes
Vinmax=Vz+Imax/1000*R;//maximum value of input voltage
printf("So the input voltage ranges from %.1f volts to %.1f volts",Vinmin,Vinmax);
|
17531b4ee8010aa23aac5a3d73809c8374c3cb8b | 449d555969bfd7befe906877abab098c6e63a0e8 | /1286/CH15/EX15.4/15_4.sce | bfe1734bebe53f56fc678ed7fc62cfe29ae0605d | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 255 | sce | 15_4.sce | clc
//initialisation
n=10
a=0.6
h=0
//CALCULATIONS
b=1-a
p=factorial(n)*a^10/(factorial(n-h)*factorial(h))
//results
printf(' \n probability of heads occurence= % 1f ',a*10)
printf(' \n probability of occuring head only in 10 throws= % 1f ',p)
|
4e831f48f3893e3ebd8eb132e9dc53b8812ee2ec | e86653ab56eded6714574f9f8f34013272027113 | /3885/CH7/EX7.11/Ex7_11.sci | e84fb2a1c07b27972a8390bc705e0413adf94fd0 | [] | no_license | FOSSEE/Xcos_TBC_Uploads | 3637554f9dca20d0c5ec2c5d00d30942edafe09a | 37e81552cb6d9066617ba91b13c91098e5ab6758 | refs/heads/master | 2023-03-30T10:45:38.033053 | 2021-03-15T05:40:35 | 2021-03-17T09:45:20 | 346,244,418 | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 282 | sci | Ex7_11.sci | //control systems by Nagoor Kani A
//Edition 3
//Year of publication 2015
//Scilab version 6.0.0
//operating systems windows 10
// Example 7.11
clc;
clear;
s=%s
p=poly([40 10],'s','coeff')
q=poly([0 3 4 1],'s','coeff')
sm=cont_frm(p,q)
disp(sm,'the state model in matrix form is')
|
b721c43eb801ac168d85afa6bf8f36f04bcf2c3c | c849c3d74ee4989b1a7eaade634677889296c807 | /test/neo4j_v3.1.tst | 1b05102282fd547292a02adcb9fbc9b8147430cb | [
"Apache-2.0"
] | permissive | colinsongf/ocparse | e2589e6dbb47b96a0cefd84da901b04d06f808ed | 142026e2a7396efa6e26d644d60490978ef4b233 | refs/heads/master | 2021-01-11T13:40:39.859192 | 2017-05-03T14:36:05 | 2017-05-03T14:36:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Scilab | false | false | 62,520 | tst | neo4j_v3.1.tst | %%-*- mode: erlang -*-
%%-*- coding: utf-8 -*-
% Test query options
[{tests, []}].
%%
%% TESTS
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.2 Patterns in practice
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.2.1. Creating data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
CREATE (:Movie { title:\"The Matrix\",released:1997 })
".
"
CREATE (p:Person { name:\"Keanu Reeves\", born:1964 })
RETURN p
".
"
CREATE (a:Person { name:\"Tom Hanks\",
born:1956 })-[r:ACTED_IN { roles: [\"Forrest\"]}]->(m:Movie { title:\"Forrest Gump\",released:1994 })
CREATE (d:Person { name:\"Robert Zemeckis\", born:1951 })-[:DIRECTED]->(m)
RETURN a,d,r,m
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.2.2. Matching patterns
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (m:Movie)
RETURN m
".
"
MATCH (p:Person { name:\"Keanu Reeves\" })
RETURN p
".
"
MATCH (p:Person { name:\"Tom Hanks\" })-[r:ACTED_IN]->(m:Movie)
RETURN m.title, r.roles
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.2.3 Attaching structures
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (p:Person { name:\"Tom Hanks\" })
CREATE (m:Movie { title:\"Cloud Atlas\",released:2012 })
CREATE (p)-[r:ACTED_IN { roles: ['Zachry']}]->(m)
RETURN p,r,m
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.2.4. Completing patterns
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MERGE (m:Movie { title:\"Cloud Atlas\" })
ON CREATE SET m.released = 2012
RETURN m
".
"
MATCH (m:Movie { title:\"Cloud Atlas\" })
MATCH (p:Person { name:\"Tom Hanks\" })
MERGE (p)-[r:ACTED_IN]->(m)
ON CREATE SET r.roles =['Zachry']
RETURN p,r,m
".
"
CREATE (y:Year { year:2014 })
MERGE (y)<-[:IN_YEAR]-(m10:Month { month:10 })
MERGE (y)<-[:IN_YEAR]-(m11:Month { month:11 })
RETURN y,m10,m11
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.3 Getting correct results
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
CREATE (matrix:Movie { title:\"The Matrix\",released:1997 })
CREATE (cloudAtlas:Movie { title:\"Cloud Atlas\",released:2012 })
CREATE (forrestGump:Movie { title:\"Forrest Gump\",released:1994 })
CREATE (keanu:Person { name:\"Keanu Reeves\", born:1964 })
CREATE (robert:Person { name:\"Robert Zemeckis\", born:1951 })
CREATE (tom:Person { name:\"Tom Hanks\", born:1956 })
CREATE (tom)-[:ACTED_IN { roles: [\"Forrest\"]}]->(forrestGump)
CREATE (tom)-[:ACTED_IN { roles: ['Zachry']}]->(cloudAtlas)
CREATE (robert)-[:DIRECTED]->(forrestGump)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.3.1. Filtering results
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (m:Movie)
WHERE m.title = \"The Matrix\"
RETURN m
".
"
MATCH (m:Movie { title: \"The Matrix\" })
RETURN m
".
"
MATCH (p:Person)-[r:ACTED_IN]->(m:Movie)
WHERE p.name =~ \"K.+\" OR m.released > 2000 OR \"Neo\" IN r.roles
RETURN p,r,m
".
"
MATCH (p:Person)-[:ACTED_IN]->(m)
WHERE NOT (p)-[:DIRECTED]->()
RETURN p,m
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.3.2. Returning results
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (p:Person)
RETURN p, p.name AS name, upper(p.name), coalesce(p.nickname,\"n/a\") AS nickname, { name: p.name,
label:head(labels(p))} AS person
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.3.3. Aggregating information
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (:Person)
RETURN count(*) AS people
".
"
MATCH (actor:Person)-[:ACTED_IN]->(movie:Movie)<-[:DIRECTED]-(director:Person)
RETURN actor,director,count(*) AS collaborations
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.3.4. Ordering and pagination
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a:Person)-[:ACTED_IN]->(m:Movie)
RETURN a,count(*) AS appearances
ORDER BY appearances DESC LIMIT 10;
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.3.5. Collecting aggregation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (m:Movie)<-[:ACTED_IN]-(a:Person)
RETURN m.title AS movie, collect(a.name) AS cast, count(*) AS actors
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.4 Composing large statements
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
CREATE (matrix:Movie { title:\"The Matrix\",released:1997 })
CREATE (cloudAtlas:Movie { title:\"Cloud Atlas\",released:2012 })
CREATE (forrestGump:Movie { title:\"Forrest Gump\",released:1994 })
CREATE (keanu:Person { name:\"Keanu Reeves\", born:1964 })
CREATE (robert:Person { name:\"Robert Zemeckis\", born:1951 })
CREATE (tom:Person { name:\"Tom Hanks\", born:1956 })
CREATE (tom)-[:ACTED_IN { roles: [\"Forrest\"]}]->(forrestGump)
CREATE (tom)-[:ACTED_IN { roles: ['Zachry']}]->(cloudAtlas)
CREATE (robert)-[:DIRECTED]->(forrestGump)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.4.1. UNION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (actor:Person)-[r:ACTED_IN]->(movie:Movie)
RETURN actor.name AS name, type(r) AS acted_in, movie.title AS title
UNION
MATCH (director:Person)-[r:DIRECTED]->(movie:Movie)
RETURN director.name AS name, type(r) AS acted_in, movie.title AS title
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.4.2. WITH
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (person:Person)-[:ACTED_IN]->(m:Movie)
WITH person, count(*) AS appearances, collect(m.title) AS movies
WHERE appearances > 1
RETURN person.name, appearances, movies
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.5 Constraints and indexes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.5.1. Using constraints
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
% "
% CREATE CONSTRAINT ON (movie:Movie) ASSERT movie.title IS UNIQUE
% ".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.5.2. Using indexes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
% "
% CREATE INDEX ON :Actor(name)
% ".
"
CREATE (actor:Actor { name:\"Tom Hanks\" }),(movie:Movie { title:'Sleepless IN Seattle' }),
(actor)-[:ACTED_IN]->(movie);
".
"
MATCH (actor:Actor { name: \"Tom Hanks\" })
RETURN actor;
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 4.6. Importing CSV files with Cypher
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
% "
% LOAD CSV WITH HEADERS FROM \"{csv-dir}/import/persons.csv\" AS csvLine
% CREATE (p:Person { id: toInt(csvLine.id), name: csvLine.name })
% ".
% not supported
% "
% CREATE INDEX ON :Country(name)
% ".
% not supported
% "
% LOAD CSV WITH HEADERS FROM \"{csv-dir}/import/movies.csv\" AS csvLine
% MERGE (country:Country { name: csvLine.country })
% CREATE (movie:Movie { id: toInt(csvLine.id), title: csvLine.title, year:toInt(csvLine.year)})
% CREATE (movie)-[:MADE_IN]->(country)
% ".
% not supported
% "
% CREATE CONSTRAINT ON (person:Person) ASSERT person.id IS UNIQUE
% ".
% not supported
% "
% CREATE CONSTRAINT ON (movie:Movie) ASSERT movie.id IS UNIQUE
% ".
% not supported
% "
% USING PERIODIC COMMIT 500
% LOAD CSV WITH HEADERS FROM \"{csv-dir}/import/roles.csv\" AS csvLine
% MATCH (person:Person { id: toInt(csvLine.personId)}),(movie:Movie { id: toInt(csvLine.movieId)})
% CREATE (person)-[:PLAYED { role: csvLine.role }]->(movie)
% ".
% not supported
% "
% DROP CONSTRAINT ON (person:Person) ASSERT person.id IS UNIQUE
% ".
% not supported
% "
% DROP CONSTRAINT ON (movie:Movie) ASSERT movie.id IS UNIQUE
% ".
"
MATCH (n)
WHERE n:Person OR n:Movie
REMOVE n.id
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 5.1 What is Cypher?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (john {name: 'John'})-[:friend]->()-[:friend]->(fof)
RETURN john.name, fof.name
".
"
MATCH (user)-[:friend]->(follower)
WHERE user.name IN ['Joe', 'John', 'Sara', 'Maria', 'Steve'] AND follower.name =~ 'S.*'
RETURN user.name, follower.name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 5.2 Querying and updating the graph
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 5.2.1. The structure of update queries
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n {name: 'John'})-[:FRIEND]-(friend)
WITH n, count(friend) AS friendsCount
WHERE friendsCount > 3
RETURN n, friendsCount
".
"
MATCH (n {name: 'John'})-[:FRIEND]-(friend)
WITH n, count(friend) AS friendsCount
SET n.friendCount = friendsCount
RETURN n.friendsCount
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 5.4 Uniqueness
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
CREATE (adam:User { name: 'Adam' }),(pernilla:User { name: 'Pernilla' }),(david:User { name: 'David' }),
(adam)-[:FRIEND]->(pernilla),(pernilla)-[:FRIEND]->(david)
".
"
MATCH (user:User { name: 'Adam' })-[r1:FRIEND]-()-[r2:FRIEND]-(friend_of_a_friend)
RETURN friend_of_a_friend.name AS fofName
".
"
MATCH (user:User { name: 'Adam' })-[r1:FRIEND]-(friend)
MATCH (friend)-[r2:FRIEND]-(friend_of_a_friend)
RETURN friend_of_a_friend.name AS fofName
".
"
MATCH (user:User { name: 'Adam' })-[r1:FRIEND]-(friend),(friend)-[r2:FRIEND]-(friend_of_a_friend)
RETURN friend_of_a_friend.name AS fofName
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 5.5 Compatibility
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
% "
% CYPHER 2.3
% START n=node:nodes(name = \"A\")
% RETURN n
% ".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 5.5.1. Accessing entities by id via START
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
% "
% CYPHER 1.9
% START n=node(42)
% RETURN n
% ".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.2 Expressions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.2.3. Case Expressions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
RETURN
CASE n.eyes
WHEN 'blue'
THEN 1
WHEN 'brown'
THEN 2
ELSE 3 END AS result
".
"
MATCH (n)
RETURN
CASE
WHEN n.eyes = 'blue'
THEN 1
WHEN n.age < 40
THEN 2
ELSE 3 END AS result
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.3 Variables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)-->(b)
RETURN b
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4 Parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4.1. String literal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE n.name = $name
RETURN n
".
"
MATCH (n { name: $name })
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4.2. Regular expression
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE n.name =~ $regex
RETURN n.name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4.3. Case-sensitive string pattern matching
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE n.name STARTS WITH $name
RETURN n.name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4.4. Create node with properties
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
CREATE ($props)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4.5. Create multiple nodes with properties
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
UNWIND $props AS properties
CREATE (n:Person)
SET n = properties
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4.6. Setting all properties on node
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n:Person)
WHERE n.name='Michaela'
SET n = $props
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4.7. SKIP and LIMIT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n:Person)
RETURN n.name
SKIP $s
LIMIT $l
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4.8. Node id
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE id(n)= $id
RETURN n.name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4.9. Multiple node ids
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE id(n) IN $ids
RETURN n.name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4.10. Calling procedures
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
% "
% CALL db.resampleIndex($indexname)
% ".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4.11. Index query (legacy indexes)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
% "
% START n=node:people(name = $value)
% RETURN n
% ".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.4.12. Index query (legacy indexes)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
% "
% START n=node:people($query)
% RETURN n
% ".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.5 Operators
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.5.2. General operators
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
CREATE (a:Person { name: 'Anne', eyeColor: 'blue' }),(b:Person { name: 'Bill',
eyeColor: 'brown' }),(c:Person { name: 'Carol', eyeColor: 'blue' })
WITH a, b, c
MATCH (p:Person)
RETURN DISTINCT p.eyeColor
".
"
WITH { person: { name: 'Anne', age: 25 }} AS p
RETURN p.person.name
".
"
CREATE (a:Restaurant { name: 'Hungry Jo', rating_hygiene: 10,
rating_food: 7 }),(b:Restaurant { name: 'Buttercup Tea Rooms', rating_hygiene: 5,
rating_food: 6 }),(c1:Category { name: 'hygiene' }),(c2:Category { name: 'food' })
WITH a, b, c1, c2
MATCH (restaurant:Restaurant),(category:Category)
WHERE restaurant[\"rating_\" + category.name]> 6
RETURN DISTINCT restaurant.name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.5.3. Mathematical operators
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
WITH 2 AS number, 3 AS exponent
RETURN number ^ exponent AS result
".
"
WITH -3 AS a, 4 AS b
RETURN b - a AS result
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.5.4. Comparison operators
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
WITH 4 AS one, 3 AS two
RETURN one > two AS result
".
"
WITH ['John', 'Mark', 'Jonathan', 'Bill'] AS somenames
UNWIND somenames AS names
WITH names AS candidate
WHERE candidate STARTS WITH 'Jo'
RETURN candidate
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.5.5. Boolean operators
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
WITH [2, 4, 7, 9, 12] AS numberlist
UNWIND numberlist AS number
WITH number
WHERE number = 4 OR (number > 6 AND number < 10)
RETURN number
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.5.6. String operators
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
WITH ['mouse', 'chair', 'door', 'house'] AS wordlist
UNWIND wordlist AS word
WITH word
WHERE word =~ '.*ous.*'
RETURN word
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.5.7. List operators
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN [1,2,3,4,5]+[6,7] AS myList
".
"
WITH [2, 3, 4, 5] AS numberlist
UNWIND numberlist AS number
WITH number
WHERE number IN [2, 3, 8]
RETURN number
".
"
WITH ['Anne', 'John', 'Bill', 'Diane', 'Eve'] AS names
RETURN names[1..3] AS result
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.5.11. Chaining Comparison Operations
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n) WHERE 21 < n.age <= 30 RETURN n
".
"
MATCH (n) WHERE 21 < n.age AND n.age <= 30 RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.6 Comments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported since comments are ignored
% "
% MATCH (n) RETURN n //This is an end of line comment
% ".
% not supported since comments are ignored
% "
% MATCH (n)
% //This is a whole line comment
% RETURN n
% ".
% not supported since comments are ignored
% "
% MATCH (n) WHERE n.property = '//This is NOT a comment' RETURN n
% ".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.7 Patterns
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.7.5. Patterns for relationships
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (me)-[:KNOWS*1..2]-(remote_friend)
WHERE me.name = 'Filipa'
RETURN remote_friend.name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.8 Lists
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.8.1. Lists in general
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] AS list
".
"
RETURN range(0, 10)[3]
".
"
RETURN range(0, 10)[-3]
".
"
RETURN range(0, 10)[0..3]
".
"
RETURN range(0, 10)[0..-5]
".
"
RETURN range(0, 10)[-5..]
".
"
RETURN range(0, 10)[..4]
".
"
RETURN range(0, 10)[15]
".
"
RETURN range(0, 10)[5..15]
".
"
RETURN size(range(0, 10)[0..3])
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.8.2. List comprehension
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN [x IN range(0,10) WHERE x % 2 = 0 | x^3] AS result
".
"
RETURN [x IN range(0,10) WHERE x % 2 = 0] AS result
".
"
RETURN [x IN range(0,10)| x^3] AS result
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.8.3. Pattern comprehension
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a:Person { name: 'Charlie Sheen' })
RETURN [(a)-->(b) WHERE b:Movie | b.year] AS years
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.8.4. Literal maps
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN { key: 'Value', listKey: [{ inner: 'Map1' }, { inner: 'Map2' }]}
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 6.8.5. Map Projection
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.1 MATCH
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.1.2. Basic node finding
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
RETURN n
".
"
MATCH (movie:Movie)
RETURN movie.title
".
"
MATCH (director { name: 'Oliver Stone' })--(movie)
RETURN movie.title
".
"
MATCH (:Person { name: 'Oliver Stone' })--(movie:Movie)
RETURN movie.title
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.1.3. Relationship basics
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (:Person { name: 'Oliver Stone' })-->(movie)
RETURN movie.title
".
"
MATCH (:Person { name: 'Oliver Stone' })-[r]->(movie)
RETURN type(r)
".
"
MATCH (wallstreet:Movie { title: 'Wall Street' })<-[:ACTED_IN]-(actor)
RETURN actor.name
".
"
MATCH (wallstreet { title: 'Wall Street' })<-[:ACTED_IN|:DIRECTED]-(person)
RETURN person.name
".
"
MATCH (wallstreet { title: 'Wall Street' })<-[r:ACTED_IN]-(actor)
RETURN r.role
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.1.4. Relationships in depth
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (charlie:Person { name: 'Charlie Sheen' }),(rob:Person { name: 'Rob Reiner' })
CREATE (rob)-[:`TYPE
WITH SPACE`]->(charlie)
".
"
MATCH (n { name: 'Rob Reiner' })-[r:`TYPE
WITH SPACE`]->()
RETURN type(r)
".
"
MATCH (charlie { name: 'Charlie Sheen' })-[:ACTED_IN]->(movie)<-[:DIRECTED]-(director)
RETURN movie.title, director.name
".
"
MATCH (martin { name: 'Charlie Sheen' })-[:ACTED_IN*1..3]-(movie:Movie)
RETURN movie.title
".
"
MATCH (actor { name: 'Charlie Sheen' })-[r:ACTED_IN*2]-(co_actor)
RETURN r
".
"
MATCH (charlie:Person { name: 'Charlie Sheen' }),(martin:Person { name: 'Martin Sheen' })
CREATE (charlie)-[:X { blocked: FALSE }]->(:UNBLOCKED)<-[:X { blocked: FALSE }]-(martin)
CREATE (charlie)-[:X { blocked: TRUE }]->(:BLOCKED)<-[:X { blocked: FALSE }]-(martin)
".
"
MATCH p =(charlie:Person)-[* { blocked:false }]-(martin:Person)
WHERE charlie.name = 'Charlie Sheen' AND martin.name = 'Martin Sheen'
RETURN p
".
"
MATCH (wallstreet:Movie { title: 'Wall Street' })-[*0..1]-(x)
RETURN x
".
"
MATCH p =(michael { name: 'Michael Douglas' })-->()
RETURN p
".
"
MATCH (a)-[r]-(b)
WHERE id(r)= 0
RETURN a,b
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.1.5. Shortest path
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.1.6. Get node or relationship by id
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE id(n)= 0
RETURN n
".
"
MATCH ()-[r]->()
WHERE id(r)= 0
RETURN r
".
"
MATCH (n)
WHERE id(n) IN [0, 3, 5]
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.2 OPTIONAL MATCH
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.2.2. Relationship
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a:Movie { title: 'Wall Street' })
OPTIONAL MATCH (a)-->(x)
RETURN x
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.2.3. Properties on optional elements
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a:Movie { title: 'Wall Street' })
OPTIONAL MATCH (a)-->(x)
RETURN x, x.name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.2.4. Optional typed and named relationship
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a:Movie { title: 'Wall Street' })
OPTIONAL MATCH (a)-[r:ACTS_IN]->()
RETURN r
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.3 WHERE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.3.1. Basic usage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE n.name = 'Peter' XOR (n.age < 30 AND n.name = 'Tobias') OR NOT (n.name = 'Tobias' OR n.name =
'Peter')
RETURN n
".
"
MATCH (n)
WHERE n:Swedish
RETURN n
".
"
MATCH (n)
WHERE n.age < 30
RETURN n
".
"
MATCH (n)-[k:KNOWS]->(f)
WHERE k.since < 2000
RETURN f
".
"
MATCH (n)
WHERE n[toLower($prop)]< 30
RETURN n
".
"
MATCH (n)
WHERE exists(n.belt)
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.3.2. String matching
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE n.name STARTS WITH 'Pet'
RETURN n
".
"
MATCH (n)
WHERE n.name ENDS WITH 'ter'
RETURN n
".
"
MATCH (n)
WHERE n.name CONTAINS 'ete'
RETURN n
".
"
MATCH (n)
WHERE NOT n.name ENDS WITH 's'
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.3.3. Regular expressions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE n.name =~ 'Tob.*'
RETURN n
".
% not supported
% "
% MATCH (n)
% WHERE n.address =~ 'Sweden\\/Malmo'
% RETURN n
% ".
"
MATCH (n)
WHERE n.name =~ '(?i)ANDR.*'
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.3.4. Using path patterns in WHERE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (tobias { name: 'Tobias' }),(others)
WHERE others.name IN ['Andres', 'Peter'] AND (tobias)<--(others)
RETURN others
".
"
MATCH (persons),(peter { name: 'Peter' })
WHERE NOT (persons)-->(peter)
RETURN persons
".
"
MATCH (n)
WHERE (n)-[:KNOWS]-({ name: 'Tobias' })
RETURN n
".
"
MATCH (n)-[r]->()
WHERE n.name='Andres' AND type(r)=~ 'K.*'
RETURN r
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.3.5. Lists
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE a.name IN ['Peter', 'Tobias']
RETURN a
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.3.6. Missing properties and values
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE n.belt = 'white'
RETURN n
".
"
MATCH (n)
WHERE n.belt = 'white' OR n.belt IS NULL RETURN n
ORDER BY n.name
".
"
MATCH (person)
WHERE person.name = 'Peter' AND person.belt IS NULL RETURN person
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.3.7. Using ranges
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE a.name >= 'Peter'
RETURN a
".
"
MATCH (a)
WHERE a.name > 'Andres' AND a.name < 'Tobias'
RETURN a
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.4 START
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.4.1. Get node or relationship from index
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.5. CREATE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.5.1. Create nodes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
CREATE (n)
".
"
CREATE (n),(m)
".
"
CREATE (n:Person)
".
"
CREATE (n:Person:Swedish)
".
"
CREATE (n:Person { name: 'Andres', title: 'Developer' })
".
"
CREATE (a { name: 'Andres' })
RETURN a
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.5.2. Create relationships
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a:Person),(b:Person)
WHERE a.name = 'Node A' AND b.name = 'Node B'
CREATE (a)-[r:RELTYPE]->(b)
RETURN r
".
"
MATCH (a:Person),(b:Person)
WHERE a.name = 'Node A' AND b.name = 'Node B'
CREATE (a)-[r:RELTYPE { name: a.name + '<->' + b.name }]->(b)
RETURN r
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.5.3. Create a full path
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
CREATE p =(andres { name:'Andres' })-[:WORKS_AT]->(neo)<-[:WORKS_AT]-(michael { name: 'Michael' })
RETURN p
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.5.4. Use parameters with CREATE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
CREATE (n:Person $props)
RETURN n
".
"
UNWIND $props AS map
CREATE (n)
SET n = map
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.6. MERGE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.6.2. Merge nodes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MERGE (robert:Critic)
RETURN robert, labels(robert)
".
"
MERGE (charlie { name: 'Charlie Sheen', age: 10 })
RETURN charlie
".
"
MERGE (michael:Person { name: 'Michael Douglas' })
RETURN michael.name, michael.bornIn
".
"
MATCH (person:Person)
MERGE (city:City { name: person.bornIn })
RETURN person.name, person.bornIn, city
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.6.3. Use ON CREATE and ON MATCH
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MERGE (keanu:Person { name: 'Keanu Reeves' })
ON CREATE SET keanu.created = timestamp()
RETURN keanu.name, keanu.created
".
"
MERGE (person:Person)
ON MATCH SET person.found = TRUE RETURN person.name, person.found
".
"
MERGE (keanu:Person { name: 'Keanu Reeves' })
ON CREATE SET keanu.created = timestamp()
ON MATCH SET keanu.lastSeen = timestamp()
RETURN keanu.name, keanu.created, keanu.lastSeen
".
"
MERGE (person:Person)
ON MATCH SET person.found = TRUE , person.lastAccessed = timestamp()
RETURN person.name, person.found, person.lastAccessed
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.6.4. Merge relationships
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (charlie:Person { name: 'Charlie Sheen' }),(wallStreet:Movie { title: 'Wall Street' })
MERGE (charlie)-[r:ACTED_IN]->(wallStreet)
RETURN charlie.name, type(r), wallStreet.title
".
"
MATCH (oliver:Person { name: 'Oliver Stone' }),(reiner:Person { name: 'Rob Reiner' })
MERGE (oliver)-[:DIRECTED]->(movie:Movie)<-[:ACTED_IN]-(reiner)
RETURN movie
".
"
MATCH (charlie:Person { name: 'Charlie Sheen' }),(oliver:Person { name: 'Oliver Stone' })
MERGE (charlie)-[r:KNOWS]-(oliver)
RETURN r
".
"
MATCH (person:Person)
MERGE (city:City { name: person.bornIn })
MERGE (person)-[r:BORN_IN]->(city)
RETURN person.name, person.bornIn, city
".
"
MATCH (person:Person)
MERGE (person)-[r:HAS_CHAUFFEUR]->(chauffeur:Chauffeur { name: person.chauffeurName })
RETURN person.name, person.chauffeurName, chauffeur
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.6.5. Using unique constraints with MERGE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
% "
% CREATE CONSTRAINT ON (n:Person) ASSERT n.name IS UNIQUE;
% CREATE CONSTRAINT ON (n:Person) ASSERT n.role IS UNIQUE;
% ".
"
MERGE (laurence:Person { name: 'Laurence Fishburne' })
RETURN laurence.name
".
"
MERGE (oliver:Person { name: 'Oliver Stone' })
RETURN oliver.name, oliver.bornIn
".
"
MERGE (michael:Person { name: 'Michael Douglas', role: 'Gordon Gekko' })
RETURN michael
".
"
MERGE (oliver:Person { name: 'Oliver Stone', role: 'Gordon Gekko' })
RETURN oliver
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.6.6. Using map parameters with MERGE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MERGE (person:Person { name: $param.name, role: $param.role })
RETURN person.name, person.role
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.7. SET
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.7.1. Set a property
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'Andres' })
SET n.surname = 'Taylor'
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.7.2. Remove a property
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'Andres' })
SET n.name = NULL RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.7.3. Copying properties between nodes and relationships
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (at { name: 'Andres' }),(pn { name: 'Peter' })
SET at = pn
RETURN at, pn
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.7.4. Adding properties from maps
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (peter { name: 'Peter' })
SET peter += { hungry: TRUE , position: 'Entrepreneur' }
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.7.5. Set a property using a parameter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'Andres' })
SET n.surname = $surname
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.7.6. Set all properties using a parameter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'Andres' })
SET n = $props
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.7.7. Set multiple properties using one SET clause
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'Andres' })
SET n.position = 'Developer', n.surname = 'Taylor'
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.7.8. Set a label on a node
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'Stefan' })
SET n :German
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.7.9. Set multiple labels on a node
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'Emil' })
SET n :Swedish:Bossman
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.8. DELETE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.8.1. Delete single node
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
DETACH DELETE n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.8.2. Delete all nodes and relationships
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
DETACH DELETE n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.8.3. Delete a node with all its relationships
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'Andres' })
DETACH DELETE n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.9. REMOVE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.9.1. Remove a property
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (andres { name: 'Andres' })
REMOVE andres.age
RETURN andres
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.9.2. Remove a label from a node
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'Peter' })
REMOVE n:German
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.9.3. Removing multiple labels
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'Peter' })
REMOVE n:German:Swedish
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.10. FOREACH
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.11. CREATE UNIQUE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.12. LOAD CSV
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.13. RETURN
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.13.1. Return nodes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'B' })
RETURN n
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.13.2. Return relationships
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'A' })-[r:KNOWS]->(c)
RETURN r
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.13.3. Return property
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'A' })
RETURN n.name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.13.4. Return all elements
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH p =(a { name: 'A' })-[r]->(b)
RETURN *
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.13.5. Variable with uncommon characters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (`This isn't a common variable`)
WHERE `This isn't a common variable`.name = 'A'
RETURN `This isn't a common variable`.happy
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.13.6. Column alias
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a { name: 'A' })
RETURN a.age AS SomethingTotallyDifferent
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.13.7. Optional properties
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
RETURN n.age
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.13.8. Other expressions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a { name: 'A' })
RETURN a.age > 30, \"I'm a literal\",(a)-->()
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.13.9. Unique results
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a { name: 'A' })-->(b)
RETURN DISTINCT b
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.14. ORDER BY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.14.1. Order nodes by property
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
RETURN n
ORDER BY n.name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.14.2. Order nodes by multiple properties
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
RETURN n
ORDER BY n.age, n.name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.14.3. Order nodes in descending order
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
RETURN n
ORDER BY n.name DESC
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.14.4. Ordering null
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
RETURN n.length, n
ORDER BY n.length
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.15. LIMIT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.15.1. Return first part
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
RETURN n
ORDER BY n.name
LIMIT 3
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.15.2. Return first from expression
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
RETURN n
ORDER BY n.name
LIMIT toInt(3 * rand())+ 1
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.16. SKIP
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.16.1. Skip first three
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
RETURN n
ORDER BY n.name
SKIP 3
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.16.2. Return middle two
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
RETURN n
ORDER BY n.name
SKIP 1
LIMIT 2
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.16.3. Skip first from expression
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
RETURN n
ORDER BY n.name
SKIP toInt(3*rand())+ 1
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.17. WITH
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.17.1. Filter on aggregate function results
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (david { name: 'David' })--(otherPerson)-->()
WITH otherPerson, count(*) AS foaf
WHERE foaf > 1
RETURN otherPerson
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.17.2. Sort results before using collect on them
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WITH n
ORDER BY n.name DESC LIMIT 3
RETURN collect(n.name)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.17.3. Limit branching of your path search
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'Anders' })--(m)
WITH m
ORDER BY m.name DESC LIMIT 1
MATCH (m)--(o)
RETURN o.name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.18. UNWIND
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.18.1. Unwind a list
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
UNWIND [1, 2, 3] AS x
RETURN x
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.18.2. Create a distinct list
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.18.3. Create nodes from a list parameter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.19. UNION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.19.1. Combine two queries
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n:Actor)
RETURN n.name AS name
UNION ALL MATCH (n:Movie)
RETURN n.title AS name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.19.2. Combine two queries and remove duplicates
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n:Actor)
RETURN n.name AS name
UNION
MATCH (n:Movie)
RETURN n.title AS name
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 7.20. CALL
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.1. Predicate functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.1.1. all()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH p =(a)-[*1..3]->(b)
WHERE a.name = 'Alice' AND b.name = 'Daniel' AND ALL (x IN nodes(p) WHERE x.age > 30)
RETURN p
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.1.2. any()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE a.name = 'Eskil' AND ANY (x IN a.array WHERE x = 'one')
RETURN a
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.1.3. exists()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE exists(n.name)
RETURN n.name AS name, exists((n)-[:MARRIED]->()) AS is_married
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.1.4. none()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH p =(n)-[*1..3]->(b)
WHERE n.name = 'Alice' AND NONE (x IN nodes(p) WHERE x.age = 25)
RETURN p
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.1.5. single()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH p =(n)-->(b)
WHERE n.name = 'Alice' AND SINGLE (var IN nodes(p) WHERE var.eyes = 'blue')
RETURN p
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2. Scalar functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.1. coalesce()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE a.name = 'Alice'
RETURN coalesce(a.hairColor, a.eyes)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.2. endNode()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (x:foo)-[r]-()
RETURN endNode(r)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.3. head()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE a.name = 'Eskil'
RETURN a.array, head(a.array)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.4. id()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
RETURN id(a)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.5. last()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE a.name = 'Eskil'
RETURN a.array, last(a.array)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.6. length()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH p =(a)-->(b)-->(c)
WHERE a.name = 'Alice'
RETURN length(p)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.7. properties()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
CREATE (p:Person { name: 'Stefan', city: 'Berlin' })
RETURN properties(p)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.8. size()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN size(['Alice', 'Bob']) AS col
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.9. Size of pattern expression
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE a.name = 'Alice'
RETURN size((a)-->()-->()) AS fof
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.10. Size of string
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE size(a.name)> 6
RETURN size(a.name)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.11. startNode()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN timestamp()
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.12. timestamp()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE a.name = 'Alice'
RETURN coalesce(a.hairColor, a.eyes)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.13. toBoolean()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN toBoolean('TRUE'), toBoolean('not a boolean')
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.14. toFloat()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN toFloat('11.5'), toFloat('not a number')
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.15. toInteger()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN toInteger('42'), toInteger('not a number')
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.2.16. type()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)-[r]->()
WHERE n.name = 'Alice'
RETURN type(r)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.3. Aggregating functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.3.1. avg()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n:Person)
RETURN avg(n.age)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.3.2. collect()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n:Person)
RETURN collect(n.age)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.3.3. count()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n { name: 'A' })-->(x)
RETURN labels(n), n.age, count(*)
".
"
MATCH (n { name: 'A' })-[r]->()
RETURN type(r), count(*)
".
"
MATCH (n { name: 'A' })-->(x)
RETURN count(x)
".
"
MATCH (n:Person)
RETURN count(n.age)
".
"
MATCH (me:Person)-->(friend:Person)-->(friend_of_friend:Person)
WHERE me.name = 'A'
RETURN count(DISTINCT friend_of_friend), count(friend_of_friend)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.3.4. max()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n:Person)
RETURN max(n.age)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.3.5. min()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n:Person)
RETURN min(n.age)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.3.6. percentileCont()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n:Person)
RETURN percentileCont(n.age, 0.4)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.3.7. percentileDisc()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n:Person)
RETURN percentileDisc(n.age, 0.5)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.3.8. stDev()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE n.name IN ['A', 'B', 'C']
RETURN stDev(n.age)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.3.9. stDevP()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n)
WHERE n.name IN ['A', 'B', 'C']
RETURN stDevP(n.age)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.3.10. sum()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n:Person)
RETURN sum(n.age)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.4. List functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.4.1. extract()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH p =(a)-->(b)-->(c)
WHERE a.name = 'Alice' AND b.name = 'Bob' AND c.name = 'Daniel'
RETURN extract(n IN nodes(p)| n.age) AS extracted
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.4.2. filter()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE a.name = 'Eskil'
RETURN a.array, filter(x IN a.array WHERE size(x)= 3)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.4.3. keys()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE a.name = 'Alice'
RETURN keys(a)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.4.4. labels()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE a.name = 'Alice'
RETURN labels(a)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.4.5. nodes()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH p =(a)-->(b)-->(c)
WHERE a.name = 'Alice' AND c.name = 'Eskil'
RETURN nodes(p)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.4.6. range()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN range(0, 10), range(2, 18, 3)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.4.7. reduce()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
% "
% MATCH p =(a)-->(b)-->(c)
% WHERE a.name = 'Alice' AND b.name = 'Bob' AND c.name = 'Daniel'
% RETURN reduce(totalAge = 0, n IN nodes(p)| totalAge + n.age) AS reduction
% ".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.4.8. relationships()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH p =(a)-->(b)-->(c)
WHERE a.name = 'Alice' AND c.name = 'Eskil'
RETURN relationships(p)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.4.9. tail()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a)
WHERE a.name = 'Eskil'
RETURN a.array, tail(a.array)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.5. Mathematical functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.5.1. Numeric functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (a),(e)
WHERE a.name = 'Alice' AND e.name = 'Eskil'
RETURN a.age, e.age, abs(a.age - e.age)
".
"
RETURN ceil(0.1)
".
"
RETURN floor(0.9)
".
"
RETURN rand()
".
"
RETURN round(3.141592)
".
"
RETURN sign(-17), sign(0.1)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.5.2. Logarithmic functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN e()
".
"
RETURN exp(2)
".
"
RETURN log(27)
".
"
RETURN log10(27)
".
"
RETURN sqrt(256)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.5.3. Trigonometric functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN acos(0.5)
".
"
RETURN asin(0.5)
".
"
RETURN atan(0.5)
".
"
RETURN atan2(0.5, 0.6)
".
"
RETURN cos(0.5)
".
"
RETURN cot(0.5)
".
"
RETURN degrees(3.14159)
".
"
RETURN haversin(0.5)
".
"
CREATE (ber:City { lat: 52.5, lon: 13.4 }),(sm:City { lat: 37.5, lon: -122.3 })
RETURN 2 * 6371 * asin(sqrt(haversin(radians(sm.lat - ber.lat))+ cos(radians(sm.lat))*
cos(radians(ber.lat))* haversin(radians(sm.lon - ber.lon)))) AS dist
".
"
RETURN pi()
".
"
RETURN radians(180)
".
"
RETURN sin(0.5)
".
"
RETURN tan(0.5)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6. String functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6.1. left()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN left('hello', 3)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6.2. lTrim()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN lTrim(' hello')
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6.3. replace()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN replace(\"hello\", \"l\", \"w\")
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6.4. reverse()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN reverse('anagram')
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6.5. right()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN right('hello', 3)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6.6. rTrim()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN rTrim('hello ')
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6.7. split()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN split('one,two', ',')
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6.8. substring()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN substring('hello', 1, 3), substring('hello', 2)
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6.9. toLower()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN toLower('HELLO')
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6.10. toString()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN toString(11.5), toString('already a string'), toString(TRUE )
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6.11. toUpper()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN toUpper('hello')
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.6.12. trim()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN trim(' hello ')
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.7. Spatial functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.7.1. distance()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
WITH point({ x: 2.3, y: 4.5, crs: 'cartesian' }) AS p1, point({ x: 1.1, y: 5.4, crs: 'cartesian' }) AS p2
RETURN distance(p1,p2) AS dist
".
"
MATCH (t:TrainStation)-[:TRAVEL_ROUTE]->(o:Office)
WITH point({ longitude: t.longitude, latitude: t.latitude }) AS trainPoint, point({ longitude:
o.longitude, latitude: o.latitude }) AS officePoint
RETURN round(distance(trainPoint, officePoint)) AS travelDistance
".
"
RETURN distance(NULL , point({ longitude: 56.7, latitude: 12.78 })) AS d
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.7.2. point() - WGS 84
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN point({ longitude: 56.7, latitude: 12.78 }) AS point
".
"
RETURN point({ x: 2.3, y: 4.5, crs: 'WGS-84' }) AS point
".
"
MATCH (p:Office)
RETURN point({ longitude: p.longitude, latitude: p.latitude }) AS officePoint
".
"
RETURN point(NULL ) AS p
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.7.3. point() - cartesian 2D
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
RETURN point({ x: 2.3, y: 4.5 }) AS point
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.8. User-defined functions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 8.8.1. Call a user-defined function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
"
MATCH (n:Member)
RETURN myFunction(collect(n.name))
".
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 9.1. Indexes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 9.2. Constraints
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% not supported
|
2203e158746d7a63022b5711f8f01ccbd9aa0666 | 449d555969bfd7befe906877abab098c6e63a0e8 | /1868/CH4/EX4.1/Ch04Ex1.sce | 80d669647d4700a9adc9c7bc0cfeb8764b07e34b | [] | no_license | FOSSEE/Scilab-TBC-Uploads | 948e5d1126d46bdd2f89a44c54ba62b0f0a1f5e1 | 7bc77cb1ed33745c720952c92b3b2747c5cbf2df | refs/heads/master | 2020-04-09T02:43:26.499817 | 2018-02-03T05:31:52 | 2018-02-03T05:31:52 | 37,975,407 | 3 | 12 | null | null | null | null | UTF-8 | Scilab | false | false | 747 | sce | Ch04Ex1.sce | // Scilab code Ex4.1: Pg 109 (2005)
clc; clear;
I = 10; // Electric current, A
t = 3600; // Time, s
q = I*t; // Electric charge liberated, C
mm_Ba = 137; // Molar mass of Barium, g
mm_Cl = 35.5; // Molar mass of Chlorine, g
valence_Ba = 2; // Valence electrons of Barium
valence_Cl = 1; // Valence electrons of Chlorine
// Using Faraday’s law of electrolysis, we have
m_Ba = (q*mm_Ba)/(96500*valence_Ba); // Mass of Barium obtained, g
m_Cl = (q*mm_Cl)/(96500*valence_Cl); // Mass of Chlorine obtained, g
printf("\nMass of Barium obtained = %4.1f g", m_Ba);
printf("\nMass of Chlorine obtained = %4.1f g", m_Cl);
// Result
// Mass of Barium obtained = 25.6 g
// Mass of Chlorine obtained = 13.2 g
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.