Create a function that is the sum of an arbitrary number of functions
조회 수: 1 (최근 30일)
이전 댓글 표시
I would like to build a generate a Bezier function for a general number of Bezier points P using the equation:
then
I generate each term in the sum as a separate cell:
n=size(P,1)-1;
for i=0:n
Bi{i+1}=@(t) nchoosek(n,i)*(1-t).^(n-i).*t.^i*P(i+1,:)
end
this gives me a cell array of function handles.
Now I want to create the total Bezier function B(t) by adding all the terms Bi(t) but I am not sure how this is done in the best way.
Can someone give me a tip how to do this?
Thanks for answer in advance!
댓글 수: 0
답변 (1개)
Walter Roberson
2019년 10월 18일
@(t) sum(cellfun(@(H) H(t), Bi))
댓글 수: 3
Walter Roberson
2019년 10월 18일
What difficulty do you observe? I just tested it on some random data and it runs without error message.
참고 항목
카테고리
Help Center 및 File Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!