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.

194 lines
4.7 KiB

3 years ago
%% Skript zum Plot Interpolieren
%Skript f<EFBFBD>r Plotbasics
basics_plot
%Kontrollpunkte definieren:
fig_Res = figure(1); % figure handle erzeugen
clf(fig_Res)
grid on
strNurbBasic = struct('p',[],'pj',[],'u',[]);
nurbs = strNurbBasic;
nurbs.u = [0,0,0,1,1,1];
nurbs.p = [2];
for i = 1:5
switch i
case 1
wi = 0.2;
lineStyle = myLineTwo;
case 2
wi = 0.6;
lineStyle = myLineThree;
case 3
wi = 1;
lineStyle = myLineOne;
case 4
wi = 2;
lineStyle = myLineFour;
case 5
wi = 4;
lineStyle = myLineFive;
end
nurbs.pj = [0 wi*1 1;0 wi*0 1;1 wi 1];
ui = 0:0.01:1;
vek = zeros(2,numel(ui));
for j = 1:numel(ui)
vek(:,j) = berechneAbleitungenAnPunkt(ui(j),nurbs.p,nurbs.u,nurbs.pj,0);
end
plot(vek(1,:),vek(2,:),'Color',lineStyle)
hold on
end
plot(nurbs.pj(1,1:end)./nurbs.pj(end,1:end),nurbs.pj(2,1:end)./nurbs.pj(end,1:end),'LineStyle','none','Marker','x','MarkerSize',8,'Color',myLineOne,'LineWidth',1.1)
grid on
xlabel('\figureXLabel')
ylabel('\figureYLabel')
set(gca,'XLim',[0,1])
set(gca,'YLim',[0,1])
%
% % scatter(P(1,:),P(2,:),'x','MarkerEdgeColor','black','LineWidth',1.5,'SizeData',400)
%
% % axis off
%
% axis equal
% hold on
%
% text(P(1,1)+0.2,P(2,1)+0.1,'$\mv{p}_{i-1}$','Interpreter','none')
% text(P(1,2)+0.1,P(2,2)+0.4,'$\mv{p}_i$','Interpreter','none')
% text(P(1,3)+0.1,P(2,3)-0.3,'$\mv{p}_{i+1}$','Interpreter','none')
% text(P(1,4)-0.9,P(2,4)+0.3,'$\mv{p}_{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_nurbsgewichte.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