MAT 581 HW 2 All

# MAT 581 HW 2 All - P2.1.3 a a=[1;2;3;4;5;6;7 z=5>>...

This preview shows pages 1–6. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: P2.1.3 a) a=[1;2;3;4;5;6;7]; z=5; >> n=length(a); >> pval=a(n); >> pval1=a(n); >> for i=n-1:-1:1; pval=z*pval+a(i); end >> for j=n-1:-1:1; pval1=(-z)*pval1+a(j); end >> x=pval/pval1 x = 1.4128 b) y=pval+pval1 y = 225152 P2.1.5 >>x=[1:0.2:3]; >>a=[1 2 3]; >>y=polyval(a,x); >>for i=length(x):-1:1 ydiff(i)=2*x(i)+a(2); end >> A=polyfit(x,y,3) A =-0.0000 1.0000 2.0000 3.0000 plot(A,'-') B=polyfit(x,ydiff,3) B =-0.0000 0.0000 2.0000 2.0000 >> plot(B,'o') C=plot(x,y,'o') C = 174.0139 P2.2.4 z= input('Enter matrix of z-values to compute: '); Enter matrix of z-values to compute: [72 382 32 12 2 3] >> n=length(z); >> L= input('Enter value of L to compute: '); Enter value of L to compute: 5 >> R= input('Enter value of R to compute: '); Enter value of R to compute: 2 >> a= input('Enter 1*6 matrix of a-values: '); Enter 1*6 matrix of a-values: [12 4 23 1 7 1] >> x= input('Enter which z(i) to compute: '); Enter which z(i) to compute: 2 >> q=a(1)+a(2)*(z(x)-L)+a(3)*((z(x)-L)^2)+a(4)*((z(x)-L)^3)+a(5)*((z(x)-L)^3)*(z(x)-R)+a(6)*((z(x)-...
View Full Document

{[ snackBarMessage ]}

### Page1 / 8

MAT 581 HW 2 All - P2.1.3 a a=[1;2;3;4;5;6;7 z=5>>...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online