sum of two inline function

조회 수: 12 (최근 30일)
dert
dert 2013년 1월 16일
Hi, i want to sum two inline function. the functions that i want to sum are following;
f1=0;
for i=1:20
f2=f2(x(1),x(2),x(3))
f1=f1+f2
end
how can i do by using inline function? the following is true??
f1=inline('0','x(1)','x(2)','x(3)');
for i=1:20
f2=inline('f2(x(1),x(2),x(3)','x(1)','x(2)','x(3)') f1=inline(['(' char(f) ')+(' char(flog) ')']);
end
Can anyone help me? Because i use this last summation function for fminsearch
  댓글 수: 1
Matt J
Matt J 2013년 1월 16일
You should probably be using Anonymous Functions as opposed to inline functions. Also, if this is for fminsearch, you should probably be writing f1 as a function of a 3x1 vector instead of 3 separate variables.

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt J
Matt J 2013년 1월 16일
편집: Matt J 2013년 1월 16일
f3 = @(x) f1(x) +f2(x)

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by