Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Problem with function handling

2 vues (au cours des 30 derniers jours)
eddie
eddie le 18 Juil 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
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 commentaire
Walter Roberson
Walter Roberson le 20 Juil 2018
Please do not close questions that have an answer.

Réponses (1)

Guillaume
Guillaume le 18 Juil 2018
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.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by