diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /1202/CH19/EX19.2 | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '1202/CH19/EX19.2')
-rwxr-xr-x | 1202/CH19/EX19.2/19_2.sce | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/1202/CH19/EX19.2/19_2.sce b/1202/CH19/EX19.2/19_2.sce new file mode 100755 index 000000000..41d38d659 --- /dev/null +++ b/1202/CH19/EX19.2/19_2.sce @@ -0,0 +1,28 @@ +clear +clc + +//Example 19.2 +disp('Example 19.2') + +function y=f_DNO3(r1) + D1=0.5;D2=0.5; + r2=0.4-0.5*r1; + y=r1*D1/(1+r1)^2/(1+r2)+r2*D2/(1+r1)/(1+r2)^2 +endfunction + +function [f, g, ind] = costf(x, ind) + f=-f_DNO3(x);//cost is negative of function to be maximised + g=-derivative(f_DNO3,x);//derivative of the cost function +endfunction + +[fopt, xopt] = optim(costf,0.5); + +disp(xopt,"Optimum value of r1=") +disp(-fopt,"Max value of DNO3=") + +mprintf('Note that the answer in book is not as accurate as the one\n... +calculated from scilab') + + + + |