PHD Project - Driver energy prediction
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.9 KiB

3 years ago
%% Skript zum Plot Poylnominterpolation
%Skript f<EFBFBD>r Plotbasics
basics_plot
clf
%tats<EFBFBD>chlich zu interpolierendes Polynom
% plot([-pi:0.01:pi],sin([-pi:0.01:pi]),'LineStyle','-','Color','black')
hold on
%Interpolation mit v=3,5,7,9 Grad
dist = 1.0;
grad = 4:2:10;
for i = 1:numel(grad)
switch i
case 1
line=myLineOne;
case 2
line=myLineTwo;
case 3
line=myLineThree;
case 4
line=myLineFour;
case 5
line=myLineFive;
case 6
line=myLineSix;
case 7
line=myLineSeven;
end
%Punkte generieren:
uvec = -dist:(2*dist/(grad(i))):dist+0.001;
rungefunc = @(x) 1./(1+25*x.^2);
pvec = rungefunc(uvec);
a = polyfit(uvec,pvec,grad(i));
y = polyval(a,[-dist:0.01:dist]);
plot([-dist:0.01:dist],y,'LineStyle','--','Color',line)
if grad(i) == 10 %Spline interpolation
xx = [-dist:0.01:dist];
yy = spline(uvec,pvec,xx);
plot(xx,yy,'LineStyle','-.','Color',myLineFive,'LineWidth',1.5)
end
end
xlabel('\figureXLabel')
ylabel('\figureYLabel')
%%
% a2 = polyfit(P(1,:),P(2,:),4);
% y2 = polyval(a2,[-5:0.01:5]);
% plot([-5:0.01:5],y2,'LineStyle','--','Color','red')
box on
grid on
plot([-dist:0.01:dist],rungefunc([-dist:0.01:dist]),'LineStyle','-','Color','black')
matlab2tikz('filename','plot_Interpolation_Polynom.tex',...
'height', '\figureheight', 'width', '\figurewidth', 'encoding', 'UTF8', 'showInfo', false, 'checkForUpdates', false, ...
'parseStrings', false, ... % switch off LaTeX parsing by matlab2tikz for titles, axes labels etc. ("greater flexibility", "use straight LaTeX for your labels")
'floatFormat', '%.4g', ... % limit precision to get smaller .tikz files
'noSize', false);