Storing found values in an array

7 ビュー (過去 30 日間)
Domenico Fazzari
Domenico Fazzari 2016 年 12 月 12 日
編集済み: Isabella Osetinsky-Tzidaki 2016 年 12 月 12 日
Hi everyone I've written an optimization code for exercise. The results are a series of xs(optimimum moles of different components in the mixture at the equilibrium) and fvals(the minimum values) for different temperatures. I would like to store in an array certain xs,precisely only the x3(7)s that satisfy my "if "condition,so i can use it in a plot. But the result isn't good,if i ask to matlab to visualize the y(j) it gives me only zeros, and I can't really understand where's my mistake. Is there anybody who can give me some tips? Here's part of the code:
for j=1:length(T)
Tj = T(j);
Gjt =Gj3(j,:);
y(j)=zeros;
b3eq = [1*FR + 1
2*FR + 4
1];
LB3 = [0 0 0 0 0 0 0 0 0 0];
x3_0 = [0 0 0 0 0 0 0 0 0 0]+1e-6;
options = optimset('Algorithm','interior-point','MaxFunEvals',1000000,'MaxIter',10000000,'TolCon',1e-12);
[x3,fval] = fmincon(@func3t,x3_0,[],[],A3eq,b3eq,LB3,[],[],options);
G3=fval*R*Tj; % kJ/mol
if x3(7)<10e-7
break
y(j)=x3(7);
end
Thanks a lot!

回答 (1 件)

Isabella Osetinsky-Tzidaki
Isabella Osetinsky-Tzidaki 2016 年 12 月 12 日
編集済み: Isabella Osetinsky-Tzidaki 2016 年 12 月 12 日
any command located between "break" and "end" cannot be performed

カテゴリ

Find more on Manual Performance Optimization in Help Center and File Exchange

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by