array of anonymous function

3 次查看(过去 30 天)
david
david 2023-6-25
评论: david 2023-6-26
hello,
I need help on anonymous function.
i need to calc array of obj [obj1, obj2, obj3] in loop each time , i call to obj with syms V and parameters value I0, IL, Rs, Rp, Vt_Ta which define before.
i try to define clussdef of obj, but get an errore.
Thanks a lot
for k=1:3
obj = @(V) I_fun(V, I0, IL, Rs, Rp, Vt_Ta) - target_value;
fplot(obj{k},[0 55],'LineWidth',2);
end

采纳的回答

Matt J
Matt J 2023-6-25
编辑:Matt J 2023-6-25
clear obj
for k=3:-1:1
obj{k} = @(V) I_fun(V, I0, IL, Rs, Rp, Vt_Ta) - target_value;
fplot(obj{k},[0 55],'LineWidth',2);
end
  5 个评论
Paul
Paul 2023-6-25
did the error arise because the for loop index variable is k (lower case) , but the index variable into the obj cell array is K (upper case)?
david
david 2023-6-26
Thank, i see it later.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Performance and Memory 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by