필터 지우기
필터 지우기

Subtracting polynomial from piecewise polynomial

조회 수: 1 (최근 30일)
Nathan Mu
Nathan Mu 2022년 4월 12일
답변: Bruno Luong 2022년 4월 12일
Hello, I have a piecewise polynomial and I want to subtract from it. How would I go about doing this?
Thanks!
  댓글 수: 1
Riccardo Scorretti
Riccardo Scorretti 2022년 4월 12일
Hi Nathan, could you post part of your code? You have a polynomial in which format? Coefficients only? Symbolic?

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

채택된 답변

Bruno Luong
Bruno Luong 2022년 4월 12일
x=cumsum(rand(1,5));
x = x-mean(x);
% Test pp
y=rand(size(x));
pp=spline(x,y);
% Here is ppsubx2 a pp-form of pp-x^2
x0=pp.breaks(1:end-1)';
ppsubx2=pp;
ppsubx2.coefs = ppsubx2.coefs - [zeros(ppsubx2.pieces,ppsubx2.order-3), ones(size(x0)), 2*x0, x0.^2];
% Check
xi = linspace(min(x),max(x));
figure
plot(xi, ppval(pp,xi)-xi.^2, 'b', xi, ppval(ppsubx2,xi), 'r+');

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by