Wie verlangsame ich in einem Diagramm das Zeichnen des Grahpen?
Show older comments
Hallo
Ich möchte in einem Plot, dass das Zeichnen des Graphen langsam beschieht, um den Verlauf sehen zu können. Im 2 Subplot, möchte dich den Graphan langsam zeichnen lassen, um den Verlauf sehen zu können. Hier der Code:
clear all % leert den Workspace
clc % leert das Command Window
close all % schliesst alle anderen offenen Fenster
A = importdata('Punkte_Interpolation.xlsx'); % importiert Daten aus Excel
A.data(1,1)
%Teilaufgabe a
B = zeros(16); % erstellt leere 16x16 Matrix
B(:,1) = A.data(:,1); % weisst der ersten Spaltte die x-Werte von A zu
for j = 2:1:16 %Laufvaable für die Spalte
for i = 1:1:17-j %Laufvariable für die Zeile
B(i,j) = (B(i+1,j-1)-B(i,j-1))/(A.data(i+j-1,3)-A.data(i,3)); % Berechnung der Tabellenwerte nach Newton
end
end
B % gibt die Matrix B aus
syms p(t)
p = B(1,1); % weisst p das Element aus der 1. Zeile und 1. Spalte zu
for m = 2:1:16
q = (t-A.data(1,3));
for k = 2:1:m-1
q = q * (t-A.data(k,3));
end
p = p + B(1,m) * q;
end
disp('Das Interpolationspolynom ist') % gibt das Interpolationspolynom aus
p
disp('Der Polynomgrad ist ') % gibt den Grad des Polynoms aus
disp(m-1)
%Teilaufgabe b
xAchse = 0:0.1:30; % definiert anzahl Rechenschritte for n = 1:length(xAchse); pp(n) = eval(subs(p,t,xAchse(n))); end subplot(2,1,1) plot(xAchse,pp) hold on plot(A.data(:,3),A.data(:,1), 'o') sp1 = spline(A.data(:,3), A.data(:,1)); plot(xAchse,ppval(sp1,xAchse),'-')
%Teilaufgabe c subplot(2,1,2) xy = [A.data(:,1).'; A.data(:,2).']; sp2 = spline(A.data(:,3), xy); yy = ppval(sp2, linspace(0,30,301)); plot(yy(1,:), yy(2,:)) hold on plot(yy(1,:), yy(2,:), 'x') plot(A.data(:,1), A.data(:,2),'o') axis equal
Answers (1)
KSSV
on 27 Oct 2016
0 votes
doc pause.
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!