필터 지우기
필터 지우기

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