Subtracting polynomial from piecewise polynomial
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Nathan Mu
am 12 Apr. 2022
Beantwortet: Bruno Luong
am 12 Apr. 2022
Hello, I have a piecewise polynomial
and I want to subtract
from it. How would I go about doing this?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/962205/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/962210/image.png)
Thanks!
1 Kommentar
Riccardo Scorretti
am 12 Apr. 2022
Hi Nathan, could you post part of your code? You have a polynomial in which format? Coefficients only? Symbolic?
Akzeptierte Antwort
Bruno Luong
am 12 Apr. 2022
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Polynomials finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!