Indexing inside a function
Show older comments
The problem i am having is i want to use fminsearch for a fuction containing every value inside my two matrixes. As i am creating a saturation line for pressure. and want it to minimize the distance between my measured Temperatures and Pressures. Basicly reduce f1-f5 to one function that i can use a singe fminsearch on. Thanks in advance!
A = 10.493056201500981;
B = 1.663772278341260e+03;
x = [A,B];
Temperature = [101.5245 106.0325 107.8912 110.6541 114.8397];
Pressure = [106.0448 122.4084 132.3047 146.6630 172.5796];
f1 = @(x) sum(abs(Pressure(1)-(1/10000)*10^(x(1)-x(2)/(273+Temperature(1)))));
f2 = @(x) sum(abs(Pressure(2)-(1/10000)*10^(x(1)-x(2)/(273+Temperature(2)))));
f3 = @(x) sum(abs(Pressure(3)-(1/10000)*10^(x(1)-x(2)/(273+Temperature(3)))));
f4 = @(x) sum(abs(Pressure(4)-(1/10000)*10^(x(1)-x(2)/(273+Temperature(4)))));
f5 = @(x) sum(abs(Pressure(5)-(1/10000)*10^(x(1)-x(2)/(273+Temperature(5)))));
Optimalisering1 = fminsearch(f1,x);
Optimalisering2 = fminsearch(f2,x);
Optimalisering3 = fminsearch(f3,x);
Optimalisering4 = fminsearch(f4,x);
Optimalisering5 = fminsearch(f5,x);
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!