フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Problem with function handling

2 ビュー (過去 30 日間)
eddie
eddie 2018 年 7 月 18 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi everyone, please if anyone can help me with this, I would be really grateful. I'm trying doing this:
fun=@(z) beta.*(abs(1-z(1).*(1-x{1}/y{1})).*abs(1-z(2).*(1-x{2}/y{2})).*...
abs(1-z(3).*(1-x{3}/y{3})).*abs(1-z(4).*(1-x{4}/y{4})))-alpha;
where:
for ii=1:size(X,1)
for i=1:m
x{i}(ii)=sum(X{ii}(n(i,1):n(i,2)));
end
end
for i=1:m
y{i}=sum(Y(n(i,1):n(i,2)));
end
There is a possibility to simplify the function "fun" (as a product) by including this, for example, into a for loop?
I'm trying using this:
for i=1:m
fun=@(z) beta.*prod(abs(1-z(i).*(1-x{i}/y{i})));
end
but it doesn't work. What should I do?
Thanks in advance
  1 件のコメント
Walter Roberson
Walter Roberson 2018 年 7 月 20 日
Please do not close questions that have an answer.

回答 (1 件)

Guillaume
Guillaume 2018 年 7 月 18 日
I'm really not clear what are variables (inputs) to your function and what are constants. Why is your anonymous function just a function of z but not also x and y? Also, why are x and y cell arrays?
As far as I can tell your equation is
result = beta * prod(1 - z .* (1 - x./y)) - alpha
assuming that z, x, and y are all vectors or matrices of the same size.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by