Question about fminunc function (iteration problem)

Hi,
I am trying to perform iterations on function f with variable 'Lb'. The code works fine but does not proceed to iterations. It says the initial value already reaches the minimum value.
[Lb,fval] = fminunc('myfunsdfsd', Lb1, options);
(Lb1 states the initial value.. 15000)
The answer should be 15000, 14800, 14560, and until it reaches 0. But I only get 15000, 15000, 15000, ...and so on.
Is there any way to make the function iterate?
f = sum(delPi1 - (delPmi + 12*mu*Lb/Wb/(H^3)*(1-(192/(pi^5)*H/Wb*tanh(pi*Wb/2/H)))^(-1) + Qb))^2;
This is function I am trying to minimize.
I have defined the other variables except Lb. I made Lb as symbolic function as well. Is that why it doesnt iterate?
Thank you in advance!!

 採用された回答

Torsten
Torsten 2015 年 7 月 20 日

0 投票

Yes, fminunc does not work with symbolic variables.
Best wishes
Torsten.

4 件のコメント

Emily
Emily 2015 年 7 月 21 日
編集済み: Walter Roberson 2015 年 7 月 21 日
One more question then,...
I neglected symbolic variable and run the file and it works. but still does not iterate.
I pasted the whole code and please see if there are any errors.
Q = 5;
H = 65;
Wm = 90;
Wb = 54;
mu = 7.974*10^(-4);
Rmi1 = 2.773*10^(-7);
x1 = 0.065490496;
x2 = 0.162925732;
LbTj = 30000;
% 1st value
x=1;
Lb1 = 16800;
Qb0 = 0;
Qb1 = ((Q - Qb0) * x1)/(1+x1);
Rb1 = 12*mu*Lb1 /Wb/(H^3)*(1-(192/(pi^5)*H/Wb*tanh(pi*Wb/2/H)))^(-1);
delPmi1 = Rmi1*Q;
delPb1 = Rb1 + Qb1;
delPi1 = delPmi1 + delPb1;
Qb = ones(1,48)*Qb1;
Rb = ones(1,48)*Rb1;
delPmi = ones(1,48)*delPmi1;
delPb = ones(1,48)*delPb1;
delPi = [delPi1];
for x=2:48
Qb(x) = ((Q - sum(Qb(x-1:1))) * x1)/(1+x1);
Rb(x) = 12*mu*Lb1/Wb/(H^3)*(1-(192/(pi^5)*H/Wb*tanh(pi*Wb/2/H)))^(-1);
delPmi(x) = delPmi(x-1) + Rmi1*(Q-sum(Qb(x-1:1)));
delPb(x) = Rb(x) + Qb(x);
delPi(x) = delPmi(x) + delPb(x);
end
f = sum(delPi1 - (delPmi + 12*mu*Lb/Wb/(H^3)*(1-(192/(pi^5)*H/Wb*tanh(pi*Wb/2/H)))^(-1) + Qb))^2;
This is my function file and I think an error is Lb1 in the for loop. Its supposed to be Lb but Lb wont produce any values for Rb. so I instead substituted Lb1.
So, to summarize, Lb is variable I want to iterate. function is the sum of pressure drop differences.
Thank you in advance!
Torsten
Torsten 2015 年 7 月 21 日
It would be of great help to have the equations you are using in a mathematical notation.
Are you sure you want to have f as above and not
f = sum((delPi1 - (delPmi + 12*mu*Lb/Wb/(H^3)*(1-(192/(pi^5)*H/Wb*tanh(pi*Wb/2/H)))^(-1) + Qb)).^2);
?
Best wishes
Torsten.
Emily
Emily 2015 年 7 月 22 日
編集済み: Walter Roberson 2015 年 7 月 22 日
Yes you are right.
I am just verifying the excel data so I don't have them in mathematical notation. To clarify, the objective function is the sum error of pressure drops for each length (Lb).
So does the code seem to make sense so far?
I added another for loop for Lb(Lb's lower bound:0, upper bound:16800)
for x=2:48
Qb(x) = ((Q - sum(Qb(x-1:1))) * x1)/(1+x1);
for Lb=0:16800
Rb(x) = 12*mu*Lb1/Wb/(H^3)*(1-(192/(pi^5)*H/Wb*tanh(pi*Wb/2/H)))^(-1);
end
delPmi(x) = delPmi(x-1) + Rmi1*(Q-sum(Qb(x-1:1)));
delPb(x) = Rb(x) + Qb(x);
delPi(x) = delPmi(x) + delPb(x);
end
Torsten
Torsten 2015 年 7 月 22 日
To be honest: I don't understand what you are trying to do.
So more information about the background of your problem and about the above calculations is needed in order to help.
Sorry.
Best wishes
Torsten.

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

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2015 年 7 月 20 日

コメント済み:

2015 年 7 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by