diff options
author | Brijeshcr | 2017-07-07 19:57:00 +0530 |
---|---|---|
committer | Brijeshcr | 2017-07-07 19:57:00 +0530 |
commit | eb4fd4f84b56a9b8f1976a67461f2c918edede32 (patch) | |
tree | ad6032b0992e679f9d69e98074141267888f5c03 /tests/unit_tests | |
parent | aa250753b439916e4df235839e9266f058632f80 (diff) | |
parent | 936bd00d2855553f52d682494814804065c7b99e (diff) | |
download | Scilab2C_fossee_old-eb4fd4f84b56a9b8f1976a67461f2c918edede32.tar.gz Scilab2C_fossee_old-eb4fd4f84b56a9b8f1976a67461f2c918edede32.tar.bz2 Scilab2C_fossee_old-eb4fd4f84b56a9b8f1976a67461f2c918edede32.zip |
Signal Processing and Demos Updated
Diffstat (limited to 'tests/unit_tests')
17 files changed, 193 insertions, 0 deletions
diff --git a/tests/unit_tests/test_analogFilters/scilabcode/main.sci b/tests/unit_tests/test_analogFilters/scilabcode/main.sci new file mode 100644 index 0000000..85fc494 --- /dev/null +++ b/tests/unit_tests/test_analogFilters/scilabcode/main.sci @@ -0,0 +1,33 @@ +// This is the demo function to test the analog filters +// They are of 4 types butterworth,chebyshev-1,chebyshev-2 and elliptic +// We are going to test here the butterworth, chebyshev-1 and chebyshev-2 filters +//zpbutt->butterworth filter +//zpch1 ->chebyshev type-1 filter +//zpch2 ->chebyshev type-2 filter +function main() + n=5; //n is the filter order + fl=3; //fl is the cutoff frequency + [pb,gb]=zpbutt(n,fl); + disp("poles of butterworth filter") + disp(pb); + disp("gain of butterworth filter"); + disp(gb); + + e=0.5; //e (epsilon) it is the ripples in pass band + wc=4; // wc cutoff frequency + [pc1,gc1]=zpch1(n,e,wc); + disp("poles of chebyshev-1 filter") + disp(pc1); + disp("gain of chebyshev-1 filter") + disp(gc1); + + a=4; //a is the attenuation in stop band + w=5; //w (omega) is the cutoff frequency + [zc2,pc2,gc2]=zpch2(n,a,w); + disp("zeros of chebyshev-2 filter") + disp(zc2); + disp("poles of chebyshev-2 filter") + disp(pc2); + disp("gain of chebyshev-2 filter") + disp(gc2); +endfunction diff --git a/tests/unit_tests/test_analogFilters/scilabcode/zpbutttest.sci b/tests/unit_tests/test_analogFilters/scilabcode/zpbutttest.sci new file mode 100644 index 0000000..1ea723d --- /dev/null +++ b/tests/unit_tests/test_analogFilters/scilabcode/zpbutttest.sci @@ -0,0 +1,7 @@ +function zpbutttest() + n=5; + fl=3; + [p,g]=zpbutt(n,fl); + disp(p); + disp(g); +endfunction diff --git a/tests/unit_tests/test_analogFilters/scilabcode/zpch1test.sci b/tests/unit_tests/test_analogFilters/scilabcode/zpch1test.sci new file mode 100644 index 0000000..4f29e0d4 --- /dev/null +++ b/tests/unit_tests/test_analogFilters/scilabcode/zpch1test.sci @@ -0,0 +1,9 @@ +function zpch1test() + + N=5; //N is the filter order + e=0.5; //e (epsilon) it is the ripples in pass band + wc=4; // wc cutoff frequency + [p,g]=zpch1(N,e,wc); + disp(p); + disp(g); +endfunction diff --git a/tests/unit_tests/test_analogFilters/scilabcode/zpch2test.sci b/tests/unit_tests/test_analogFilters/scilabcode/zpch2test.sci new file mode 100644 index 0000000..665fb41 --- /dev/null +++ b/tests/unit_tests/test_analogFilters/scilabcode/zpch2test.sci @@ -0,0 +1,9 @@ +function zpch2test() + n=5; + a=4; + w=5; + [z,p,g]=zpch2(n,a,w); + disp(z); + disp(p); + disp(g); +endfunction diff --git a/tests/unit_tests/test_filterResponse/scilabcode/buttmagtest.sci b/tests/unit_tests/test_filterResponse/scilabcode/buttmagtest.sci new file mode 100644 index 0000000..c7426c2 --- /dev/null +++ b/tests/unit_tests/test_filterResponse/scilabcode/buttmagtest.sci @@ -0,0 +1,7 @@ +function buttmagtest() + smp=[1:5]; + od=6; + frq=2.2; + oup=buttmag(od,frq,smp); + disp(oup); +endfunction diff --git a/tests/unit_tests/test_filterResponse/scilabcode/cheb1magtest.sci b/tests/unit_tests/test_filterResponse/scilabcode/cheb1magtest.sci new file mode 100644 index 0000000..7d09637 --- /dev/null +++ b/tests/unit_tests/test_filterResponse/scilabcode/cheb1magtest.sci @@ -0,0 +1,8 @@ +function cheb1magtest() + od=5; + wfc=3; + eps=0.3; + sap=[1:5]; + out=cheb1mag(od,wfc,eps,sap); + disp(out); +endfunction diff --git a/tests/unit_tests/test_filterResponse/scilabcode/ell1magtest.sci b/tests/unit_tests/test_filterResponse/scilabcode/ell1magtest.sci new file mode 100644 index 0000000..b53c435 --- /dev/null +++ b/tests/unit_tests/test_filterResponse/scilabcode/ell1magtest.sci @@ -0,0 +1,7 @@ +function ell1magtest() + eps1=0.2; + m11=0.4; + z1=[1,2,3]; + [s1]=ell1mag(eps1,m11,z1); + disp(s1); +endfunction diff --git a/tests/unit_tests/test_filterResponse/scilabcode/main.sci b/tests/unit_tests/test_filterResponse/scilabcode/main.sci new file mode 100644 index 0000000..6a8cbc5 --- /dev/null +++ b/tests/unit_tests/test_filterResponse/scilabcode/main.sci @@ -0,0 +1,20 @@ +function main() + + order=5; + sample1=[1:5]; + frq=2.2; + out1=buttmag(order,frq,sample1); + disp(out1); + + wfc=3; + eps=0.3; + sample2=[1:5]; + out2=cheb1mag(order,wfc,eps,sample2); + disp(out2); + + eps1=0.2; + m11=0.4; + z1=[1,2,3]; + [s1]=ell1mag(eps1,m11,z1); + disp(s1); +endfunction diff --git a/tests/unit_tests/test_jacobi/scilabcode/main.sci b/tests/unit_tests/test_jacobi/scilabcode/main.sci new file mode 100644 index 0000000..ee229eb --- /dev/null +++ b/tests/unit_tests/test_jacobi/scilabcode/main.sci @@ -0,0 +1,18 @@ +// Demo function to test %sn and %k functions +// %sn is the Jacobi's elliptic function +// %k is the Jacobi's complete integral +function main() + u=[1+2*%i 2+3*%i 3+1*%i]; // the corresponding complex vector + k=0.6; // parameter of elliptic integral + [out]=%sn(u,k); + disp(out); + m=[0.1 0.2 0.3]; // parametrt of Jacobi complete integral + s=%k(m); + disp(s); +endfunction + +//Output +//for %sn +// 1.5641568 - 0.2037920i 1.0580372 + 0.0100213i 1.1386855 - 0.4631921i +// for %k +// 1.6124413 1.6596236 1.7138894 diff --git a/tests/unit_tests/test_jacobi/scilabcode/modktest.sci b/tests/unit_tests/test_jacobi/scilabcode/modktest.sci new file mode 100644 index 0000000..613cd33 --- /dev/null +++ b/tests/unit_tests/test_jacobi/scilabcode/modktest.sci @@ -0,0 +1,5 @@ +function modktest() + m=[0.1 0.2 0.3]; + s=%k(m); + disp(s); +endfunction diff --git a/tests/unit_tests/test_jacobi/scilabcode/modsntest.sci b/tests/unit_tests/test_jacobi/scilabcode/modsntest.sci new file mode 100644 index 0000000..dc5d435 --- /dev/null +++ b/tests/unit_tests/test_jacobi/scilabcode/modsntest.sci @@ -0,0 +1,6 @@ +function modsntest() + u=[1+2*%i 2+3*%i 3+1*%i]; // the corresponding complex vector + k=0.6; // parameter of elliptic integral + [out]=%sn(u,k); + disp(out); +endfunction diff --git a/tests/unit_tests/test_string/scilabcode/asciitest.sci b/tests/unit_tests/test_string/scilabcode/asciitest.sci new file mode 100644 index 0000000..aa0017d --- /dev/null +++ b/tests/unit_tests/test_string/scilabcode/asciitest.sci @@ -0,0 +1,11 @@ +//This function test the ascii function in scilab. +//Ascii function takes the input string and then gives the ascii code of the string. +// The output for the scilab will be:- +//[97. 110. 107. 105. 116. 32. 105. 115. 32. 114. 97. 106.] + +function asciitest() + y="ankit is raj"; //This is the input string for testing the function. + x=ascii(y); //calling of the function + disp(x); +endfunction + diff --git a/tests/unit_tests/test_string/scilabcode/asciitest2.sci b/tests/unit_tests/test_string/scilabcode/asciitest2.sci new file mode 100644 index 0000000..ca7dcb7 --- /dev/null +++ b/tests/unit_tests/test_string/scilabcode/asciitest2.sci @@ -0,0 +1,5 @@ +function asciitest2() + d=[97 98 99 100 101]; + si=ascii(d); + disp(si); +endfunction diff --git a/tests/unit_tests/test_string/scilabcode/main.sci b/tests/unit_tests/test_string/scilabcode/main.sci new file mode 100644 index 0000000..4030ee0 --- /dev/null +++ b/tests/unit_tests/test_string/scilabcode/main.sci @@ -0,0 +1,30 @@ +//This is the demo function to test a set of string functions +// ascii->converts the input char vector/array to corresponding ascii code or vice versa +// strchr-> it finds the occurence of a charcter in a given string +// strncpy->copy charcters from string +// strspn-> get span of character set in string + +function main() + strascii1="ankit is raj"; //This is the input string for testing the function. + asciiout1=ascii(strascii1); //calling of the function + disp(asciiout1); + + strascii2=[97 98 99 100 101]; //Input as the ascii code to get converted to string + asciiout2=ascii(strascii2); //calling the function + disp(asciiout2); + + str="This is a sample string"; + ch="s"; + out1=strchr(str,ch); + disp(out1); + + ss="Ankit Raj"; + nn=5; + resu=strncpy(ss,nn); + disp(resu); + + strsample2="Hello this is Ankit"; + a="Ank"; + oup2=strspn(a,strsample2); + disp(oup2) +endfunction diff --git a/tests/unit_tests/test_string/scilabcode/strchrtest.sci b/tests/unit_tests/test_string/scilabcode/strchrtest.sci new file mode 100644 index 0000000..f8d3419 --- /dev/null +++ b/tests/unit_tests/test_string/scilabcode/strchrtest.sci @@ -0,0 +1,6 @@ +function strchrtest() + s="This is a sample string"; + ch="s"; + y=strchr(s,ch); + disp(y); +endfunction diff --git a/tests/unit_tests/test_string/scilabcode/strcspntest.sci b/tests/unit_tests/test_string/scilabcode/strcspntest.sci new file mode 100644 index 0000000..9a03c57 --- /dev/null +++ b/tests/unit_tests/test_string/scilabcode/strcspntest.sci @@ -0,0 +1,6 @@ +function strcspntest() + x="123243545assdsc"; + y="anki5t3"; + z=strcspn(y,x); + disp(z); +endfunction diff --git a/tests/unit_tests/test_string/scilabcode/strncpytest.sci b/tests/unit_tests/test_string/scilabcode/strncpytest.sci new file mode 100644 index 0000000..14eceb8 --- /dev/null +++ b/tests/unit_tests/test_string/scilabcode/strncpytest.sci @@ -0,0 +1,6 @@ +function strncpytest() + ss="Ankit Raj"; + nn=5; + resu=strncpy(ss,nn); + disp(resu); +endfunction |