Info
此问题已关闭。 请重新打开它进行编辑或回答。
Problem with function handling
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
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.
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!