Hiiii having problem in coding optimazation function

hiii i have problem in defining objective function for optimization. my objective function is
y=sum(abs(Voc-Vbc));
where Voc is given data and Vbc is obtained by
Vbc=(((Q./C1)+(Ic*R2)).*exp(-tc./(R2.*C1)))+Vo-(Ic*(R1+R2));
in this Q tc and Ic are constant and R1 C1 R2 and Vo is obtained from
R1 = ((a(1)+a(2)*cr+a(3)*(cr^2))*exp(-a(4).*SOC))+(a(5)+a(6)*cr+a(7)*(cr^2));
R2 = ((a(8)+a(9)*cr+a(10)*(cr^2))*exp(-a(11).*SOC))+(a(12)+a(13)*cr+a(14)*(cr^2));
C1 = (-(a(15)+a(16)*cr+a(17)*(cr^2))*exp(-a(18).*SOC))+(a(19)+a(20)*cr+a(21)*(cr^2));
Vo = ((a(22)+a(23)*cr+a(24)*(cr^2))*exp(-a(25).*SOC))+(a(26)+a(27).*SOC+a(28).*(SOC.^2)+a(29).*(SOC.^3))-(a(30)*cr)+(a(31)*(cr^2));
Here SOC is an array and cr is constant a is array with (1, 31) dim . this a matrix is variable for our optimization.
in my program i want R1 C1 R2 and Vo always remain positive. how i can define it in matlab so this values always remain positive.

2 件のコメント

Alan Weiss
Alan Weiss 2015 年 3 月 13 日
Please format your question using the {} Code button so that we can read it.
Alan Weiss
MATLAB mathematical toolbox documentation
venu sangwan
venu sangwan 2015 年 3 月 15 日
i have updated it plz help

サインインしてコメントする。

回答 (1 件)

Alan Weiss
Alan Weiss 2015 年 3 月 16 日

0 投票

It is very hard to understand you, so my comments might be off base. I am not sure that I understand what your control variables are. Control variables are the ones that you change to try to optimize something.
Suppose that your control variables are R1, C1, R2, and V0. Then you write your objective function for the lsqnonlin function as
function y = myfun(x,Vbc)
R1 = x(1);
C1 = x(2);
R2 = x(3);
V0 = x(4)
% Now write the calculation of Voc
% End the calculation with
y = Voc - Vbc
and pass your function as
fun = @(x)myfun(x,Vbc); % gets the objective function
solution = lsqnonlin(fun,x0) % you need an initial guess x0
I hope this helps,
Alan Weiss
MATLAB mathematical toolbox documentation

1 件のコメント

venu sangwan
venu sangwan 2015 年 3 月 17 日
variable are a(1,31) matrix from which R1, C1, R2, and V0 are formed . then they are use to form Vbc which is use in objective function

サインインしてコメントする。

カテゴリ

質問済み:

2015 年 3 月 13 日

コメント済み:

2015 年 3 月 17 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by