Hab hier mal ne Übung online gestellt und meine Lösung dazu, kann jmd bitte drüber schauen ob das so stimmt?
clc;clear all;close all;
x=[0,1,2,3,4,5,6];
y=[1.5,2,1.4,0,0.5,-1,0];
subplot(3,1,1)
xx=linspace(-3,8,50);
n=length(x)-1;
koef=polyfit(x,y,n);
p6=polyval(koef,xx);
plot(x,y,'*')
hold on
plot(xx,p6,'-r')
xlabel('x-Achse')
ylabel('y-Achse')
xlim([-3,8])
ylim([-3,3])
u=y(5)/x(5);
quiver(x(5),y(5),x(5),y(5),0.5)
hold off
subplot(3,1,2)
y2=polyder(y);
n=length(y2)-1
y2_1=polyval(y2,xx)
y1=y'
plot(xx,y2_1,x,y1,'*')
xlabel('x-Achse')
ylabel('y-Achse')
xlim([-3,8])
subplot(3,1,3)
plot(x,y,'*')
hold on
plot(xx,p6,'-r')
xlabel('x-Achse')
ylabel('y-Achse')
xlim([-3,8])
ylim([-3,3])
quiver(x,y,x,y,0.5)
hold off
thx :)
↧