Προς το περιεχόμενο

Ασκηση στο μαtlab


georginos1989

Προτεινόμενες αναρτήσεις

Δημοσ.

Εχω την άσκηση με της διηρημενες διαφορες του newton Να λυθεί για τυχαίο αριθμό σημείων και να βρεθεί το πολυώνυμο... ¨εχω κολλήσει... Δεν ξέρω απο πού να αρχίσω... Καμια βοήθειααα....

Δημοσ.

http://matlabdb.mathematik.uni-stuttgart.de/download.jsp?MC_ID=7&MP_ID=404

http://persson.berkeley.edu/128A/lec11-2x3.pdf

Και γενικα ψαξε για newton devided differences στο google και θα βρεις πολλες ιδεες.Δεν υπαρχει στανταρ τροπος για να κανεις αυτο που θες.

 

Αν ξερεις matlab δεν θα εχεις προβλημα. An δεν το εχεις ανοιξει ποτε θα εχεις...

Αν κολλήσεις σε κάποιο σημειο και δεν καταλαβαινεις τι κανει σε καποιο παραδειγμα απ το google, εδω ειμαστε

Δημοσ.

Ξέρω matlab.. Απλώς δεν μπορώ να καταλάβω πως θα βρίσκουμε τις διηρημένες διαφορες αφού ανάλογα με την τάξη αλλάζουν κάθε φορά ο αριθμός των χ,y και το διηρημένων διαφορών... πχ για τριτης ταξης βρίσκεις στην αρχη 3 μετα 2 και μετα 1...

Δημοσ.

Βρήκα το παρακ'ατω παραδειγμα.. το μονο που δεν καταλαβαίνω είναι το τι ειναι τα xi kai yi... Μηπως μπορειτε να βοηθησετε?

 

function yi = NewtonInter(x,y,xi)

% Newton interpolation algorithm

% x,y - row-vectors of (n+1) data values (x,y)

% xi - a row-vector of x-values, where interpolation is to be found (could be a single value)

% yi - a row-vector of interpolated y-values

 

n = length(x) - 1; % the degree of interpolation polynomial

ni = length(xi); % the number of x-values, where interpolation is to be found

 

D = ones(n,n); % the matrix for Newton divided differences

% has n rows for divided differences of the corresponding order

% has n columns corresponding to data values x(1),x(2),...,x(n)

 

for k = 1 : n

D(k,1) = (y(k+1)-y(k))/(x(k+1)-x(k)); % first divided difference

end

 

for k = 2 : n % start the outer loop through the k-th order divided differences

 

for kk = 1 : (n-k+1) % start the inner loop through the data values

% the matrix of divided differences is triangular!

 

D(kk,k) = (D(kk+1,k-1) - D(kk,k-1))/(x(kk+k)-x(kk)); % see the Newton divided differences

end % end of the inner loop

 

end % the end of the outer loop

 

% define the (n+1) coefficients of the Newton interpolating polynomial

a(1) = y(1);

 

for k = 2 : (n+1)

a(k) = D(1,k-1); % the first row of the matrix of divided differences corresponds to the point x(1)

end

 

% compute values of the Newton interpolating polynomial at each x-value of xi

 

% Note: the algorithm uses the Horner's rule for polynomial evaluation,

% where the nested multiplication is performed in parallel for each x-value of the row xi

 

yi = a(n+1)*ones(1,ni); % initialization of the vector yi as the coefficient of the highest degree

 

for k = 1 : n

yi = a(n+1-k)+yi.*(xi-x(n+1-k)); % nested multiplication, where xi is a row-vector

end

 

% BONUS-PROBLEM: this program can be improved for space savings (set D as a vector rather than a matrix!)

% If you get a solution, send it to the instructor. The first student, who gets a correct solution,

% will get a bonus mark to the final mark.

Δημοσ.

Έστω μια συνάρτηση f(Χ)=αΧ+β κάποιας μεθόδου παρεμβολής (γραμμικής; δεν ξέρω κοίτα τον κώδικα), το xi (το Χ) είναι το διάνυσμα των τιμών που παίρνει σαν όρισμα η συνάρτηση (η απλά τα σημεία στα οποία θες να εφαρμόσεις την 'τάδε' μέθοδο της παρεμβολής) και το yi (f(X) ή Υ) το διάνυσμα των τιμών της εξόδου της συνάρτησης.

Δημοσ.

Είναι η newton με τις διηρημενες διαφορες.. Τα ρωταω αυτά γιατί ποιο κάτω τα χρησιμοποιεί στον κωδικα στο σημείο

 

% compute values of the Newton interpolating polynomial at each x-value of xi

 

% Note: the algorithm uses the Horner's rule for polynomial evaluation,

% where the nested multiplication is performed in parallel for each x-value of the row xi

 

yi = a(n+1)*ones(1,ni); % initialization of the vector yi as the coefficient of the highest degree

 

for k = 1 : n

yi = a(n+1-k)+yi.*(xi-x(n+1-k)); % nested multiplication, where xi is a row-vector

end

 

% BONUS-PROBLEM: this program can be improved for space savings (set D as a vector rather than a matrix!)

% If you get a solution, send it to the instructor. The first student, who gets a correct solution,

% will get a bonus mark to the final mark.

 

Αλλά δεν κατάλαβα πάλι τι κάνει αυτότο σημείο του κωδικα.. Για πείτε....

Δημοσ.

clear

clc

close all

 

t=input('Dwse thn taksh ')

 

d=zeros(t,t)

 

 

for i=1:t+1

x(i)=input('Dwse to x')

y(i)=input('Dwse to y')

end

 

 

for i=1:t

d(i,1)=(y(i+1)-y(i))/(x(i+1)-x(i))

end

 

for k=2:t

for j=1:(t-k+1)

d(j,k)=(d(j+1,k-1)-d(j,k-1))/(x(j+k)-x(j))

end

end

 

a(1)=y(1)

for i=2:t+1

a(i)=d(1,i-1)

end

 

yi = a(t+1)*ones(1,t)

%c=inv(a)*x'

%for k = 1 : t

% yi = a(t+1-k)+yi.*(xi-x(n+1-k))

%end

 

b=poly2sym(a)

 

 

 

Εχω κανει αυτο αλλά μετα πως θα το κανω να εμφανιζει το πολυωνυμο?

Πρεπει να γίνουν καποιες πραξεις με τους συντελεστες του πινακα α για να βγει το τελικο πολυωνυμο......????????

 

---------- Προσθήκη στις 20:51 ---------- Προηγούμενο μήνυμα στις 20:15 ----------

 

Καμια βοηθεια? Την έχω για αυριο την ασκηση......

 

---------- Προσθήκη στις 22:43 ---------- Προηγούμενο μήνυμα στις 20:51 ----------

 

Help!!!!!!!!!!!!

 

---------- Προσθήκη 14-01-2010 στις 01:28 ---------- Προηγούμενο μήνυμα 13-01-2010 στις 22:43 ----------

 

Καποιος που να ξερει.....

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...