|
|
|
|
%% Skript zum Plot Interpolieren
|
|
|
|
|
|
|
|
|
|
%Skript f<EFBFBD>r Plotbasics
|
|
|
|
|
basics_plot
|
|
|
|
|
|
|
|
|
|
%Kontrollpunkte definieren:
|
|
|
|
|
fig_Res = figure(1); % figure handle erzeugen
|
|
|
|
|
|
|
|
|
|
clf(fig_Res)
|
|
|
|
|
|
|
|
|
|
fig_Res.Color = [1, 1, 1]; % Hintergrundfarbe wei<EFBFBD>
|
|
|
|
|
fig_Res.Units = 'centimeters'; % figure Einheit in cm
|
|
|
|
|
fig_Res.Position(3) = 16.49765; % hier kann man in cm die richtige Breite des Texts in LaTeX angeben ...
|
|
|
|
|
fig_Res.Position(4) = 16; % und hier die H<EFBFBD>he der figure
|
|
|
|
|
|
|
|
|
|
P = [-5 -2 0.5 5;-2 4 -1 2];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
% scatter(P(1,:),P(2,:),'x','MarkerEdgeColor','black','LineWidth',1.5,'SizeData',400)
|
|
|
|
|
|
|
|
|
|
% axis off
|
|
|
|
|
|
|
|
|
|
axis equal
|
|
|
|
|
hold on
|
|
|
|
|
grid on
|
|
|
|
|
|
|
|
|
|
text(P(1,1)+0.2,P(2,1)+0.1,'$\mv{r}_{i-1}$','Interpreter','none')
|
|
|
|
|
text(P(1,2)+0.1,P(2,2)+0.4,'$\mv{r}_i$','Interpreter','none')
|
|
|
|
|
text(P(1,3)+0.1,P(2,3)-0.3,'$\mv{r}_{i+1}$','Interpreter','none')
|
|
|
|
|
text(P(1,4)-0.9,P(2,4)+0.3,'$\mv{r}_{i+2}$','Interpreter','none')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%% Polynomfit
|
|
|
|
|
%
|
|
|
|
|
% a = polyfit(P(1,:),P(2,:),3);
|
|
|
|
|
% y = polyval(a,[-5:0.01:5]);
|
|
|
|
|
% plot([-5:0.01:5],y,'LineStyle','--','Color',myLineThree)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%% Lineare Interpolation mit zirkularer Blende
|
|
|
|
|
|
|
|
|
|
% Winkelhalbierende berechnen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delta = [0,1.2,0.7,0];
|
|
|
|
|
|
|
|
|
|
for i = 2:size(P,2)-1
|
|
|
|
|
|
|
|
|
|
n1 = (P(:,i-1)-P(:,i))/norm(P(:,i-1)-P(:,i));
|
|
|
|
|
n2 = (P(:,i+1)-P(:,i))/norm(P(:,i+1)-P(:,i));
|
|
|
|
|
|
|
|
|
|
nWH = (n1+n2)/norm(n1+n2); %Richtungsvektor der Winkelhalbierenden
|
|
|
|
|
|
|
|
|
|
% WH plotten
|
|
|
|
|
|
|
|
|
|
WH = P(:,i)+[-1:0.01:4].*nWH;
|
|
|
|
|
plot(WH(1,:),WH(2,:),'LineStyle','-.','Color',myGray50)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
% Kreimittelpunkt berechnen
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SP1 = P(:,i)+delta(i).*n1;
|
|
|
|
|
SP2 = P(:,i)+delta(i).*n2;
|
|
|
|
|
|
|
|
|
|
nSenk1 = [0 1;-1 0]*n1;
|
|
|
|
|
nSenk2 = [0 1;-1 0]*n2;
|
|
|
|
|
|
|
|
|
|
lambda = [-nSenk1 nSenk2]\(SP1-SP2);
|
|
|
|
|
|
|
|
|
|
MP = SP1+lambda(1).*nSenk1;
|
|
|
|
|
MP2 = SP2+lambda(2).*nSenk2;
|
|
|
|
|
|
|
|
|
|
% plot(SP1(1),SP1(2),'Marker','o','Color',myLineOne,'MarkerEdgeColor','black','MarkerFaceColor','black')
|
|
|
|
|
% plot(SP2(1),SP2(2),'Marker','o','Color',myLineOne,'MarkerEdgeColor','black','MarkerFaceColor','black')
|
|
|
|
|
|
|
|
|
|
%Kreis Plotten
|
|
|
|
|
plot(MP(1),MP(2),'Marker','o','Color',myLineOne,'MarkerEdgeColor','black','MarkerFaceColor','black')
|
|
|
|
|
|
|
|
|
|
xval = SP1(1);
|
|
|
|
|
yval = SP1(2);
|
|
|
|
|
x = xval;
|
|
|
|
|
y = yval;
|
|
|
|
|
while xval < SP2(1)
|
|
|
|
|
xval = xval + 0.01;
|
|
|
|
|
if yval > MP(1)
|
|
|
|
|
yval = +sqrt(lambda(1)^2-(xval-MP(1))^2)+MP(2);
|
|
|
|
|
else
|
|
|
|
|
yval = -sqrt(lambda(1)^2-(xval-MP(1))^2)+MP(2);
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if imag(yval) == 0
|
|
|
|
|
x = [x, xval];
|
|
|
|
|
y = [y, yval];
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
x = [x,SP2(1)];
|
|
|
|
|
y = [y,SP2(2)];
|
|
|
|
|
|
|
|
|
|
plot(x,y,'LineStyle','-','Color',myLineTwo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
% plot(MP2(1),MP2(2),'Marker','o','Color',myLineOne,'MarkerEdgeColor','black','MarkerFaceColor','black')
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
text(P(1,2)-0.7,P(2,2)-0.2,'$\delta_i$','Interpreter','none')
|
|
|
|
|
text(P(1,3)-1.1,P(2,3)+0.3,'$\delta_{i+1}$','Interpreter','none')
|
|
|
|
|
|
|
|
|
|
plot(P(1,:),P(2,:),'LineStyle','-','Marker','o','Color',myLineOne,'MarkerEdgeColor','black','MarkerFaceColor','black','LineWidth',1,'MarkerSize',5)
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
matlab2tikz('filename','plot_Interpolation.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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hold off
|
|
|
|
|
% box off % Box um die figure herum ausblenden
|
|
|
|
|
|
|
|
|
|
|