필터 지우기
필터 지우기

how to define a vector of functions using a for cycle?

조회 수: 1 (최근 30일)
Luca Losero
Luca Losero 2019년 10월 10일
댓글: Luca Losero 2019년 10월 16일
I have defined n functions fi(t,x,y),
I want to obtain the vector:
F=@(t,x,y) [f1(t,x,y); f2(t,x,y); ... fn(t,x,y)],
without writing the vector by hand but implementing a cycle like:
for i=1:n
fi=@(t,x,y) x+3*i*y+t^2
F(i)=fi
end
  댓글 수: 3
Shubham Gupta
Shubham Gupta 2019년 10월 10일
Maybe this will help?
F = @(t,x,y)[];
for i=1:n
fi=@(t,x,y) x+3*i*y+t^2
F=@(t,x,y)[F(t,x,y);fi(t,x,y)];
end
Luca Losero
Luca Losero 2019년 10월 16일
thanks a lot, with your help I solved it

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

채택된 답변

Shivam Prasad
Shivam Prasad 2019년 10월 16일
편집: Shivam Prasad 2019년 10월 16일
Hi Luca,
Check if this works for you:
syms t x y
n=5; % define a n
F=matlabFunction(subs(x+3*i*y+t^2,i,1:n))

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by