Function handler in a for loop

1 次查看(过去 30 天)
KingsOz
KingsOz 2022-8-1
评论: KingsOz 2022-8-1
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
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.
KingsOz
KingsOz 2022-8-1
Sorry I pasted the wrong row vector for (No). (No) should have 5 elements. I will try your suggestion. (No) is a scaling function used in curve fitting a set of analysis data to match a reference data. I have two sets of plots with the same duration along the time axis (0 to 0.295). However, their peak amplitude is different in magnitude and occurs at different instances in time. My goal is to scale one of them to match the other.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by