Function handler in a for loop
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I am working on an optimization problem for curve fitting analysis data. I have tried to use a function handler to experess the data so that I can use fmincon to solve the parameters. However, i keep getting error messages : Operator '*' is not supported for operands of type 'function_handle'.
Here is code for the line with the error message:
for i = 1:60
No = [1.169, 1.724, 0.5, 1.725]; % initial values
if tp(i,1) < 0.065
ts(i,1) = P36S2_Steel_Ux(i,1) * @(No) (Lf_ref/Lf_i).^No(1) * (Cs_ref/Cs_i).^No(3) * (Ep_i/Ep_ref).^No(4)* (di/dref).^No(5);
else
ts(i,1) = P36S2_Steel_Ux(i,1) * @(No) (Lf_ref/Lf_i).^No(2) * (Cs_ref/Cs_i).^No(3) * (Ep_i/Ep_ref).^No(4)* (di/dref).^No(5);
end
end
The goal is to find the optimal values for No.
댓글 수: 2
Jan
2022년 8월 1일
The purpose of the "@(No)" is not clear. Either simply omit this part, or create ts as array of function handles:
ts{i,1} = @(No) P36S2_Steel_Ux(i,1) * (Lf_ref/Lf_i).^No(1) * ...
(Cs_ref/Cs_i).^No(3) * (Ep_i/Ep_ref).^No(4)* (di/dref).^No(5);
You provide No as 1x4 vector. Then accessing No(5) is confusing.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!