AE202 Problem Set 2 Solutions - AE202 Problem Set 2: MATLAB...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
AE202 Problem Set 2: MATLAB DUE: 23 February 2011 Spring 2011 Include a printout of your MATLAB code with your homework solutions. Email electronic copies of your MATLAB functions to cmartin6@illinois.edu . In a single zip (or rar) file named LastName_FirstName_AE202HW2.zip . Please include AE202 Homework 2 in the subject line of the email. 1. In MATLAB polynomials are stored as a vector of their coefficients. i.e. 1 1 1 0 ( ) ... nn p x a x a x a x a is stored as a vector p=[a n , a n-1 , … , a 1 , a 0 ] a. Write a MATLAB function that computes the coefficients of the polynomial that is formed by multiplying 2 other polynomials. Function should be of the form: CombinedPolyCoeff = polyMultiply ( polyCoeffA, polyCoeffB) You cannot use the inbuilt MATLAB function conv function CombinedPolyCoeff = polyMultiply(polyCoeffA,polyCoeffB) % Finds the product of 2 polynomials. % All of the input and output polynomials are stored as a vector of their % coefficients. P=a_n*x^n+…+a_1*x+a_0 =>[a_n,…,a_1,a_0] % subsequent calculations assume polyCoeffA and PolyCoeffB are column % vectors. Make sure they are. [mA nA]=size(polyCoeffA); [mB nB]=size(polyCoeffB); if mA<nA polyCoeffA=polyCoeffA'; end if mB<nB polyCoeffB=polyCoeffB'; end % compute the degree of both input polynomials nA=length(polyCoeffA)-1; nB=length(polyCoeffB)-1; % create a matrix that has the coefficients of polyA in each column % offset by one in each subsequent column A=reshape([repmat([polyCoeffA;zeros(nB+1,1)],nB,1);polyCoeffA],[],nB+1); % compute each term in the product polynomial % each row corresponds to a certain x exponent C=A*polyCoeffB; % sum the rows to get the product polynomial CombinedPolyCoeff=sum(C,2); % ensure output is correct orientation if mA<nA CombinedPolyCoeff=CombinedPolyCoeff'; end
Background image of page 1

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

View Full DocumentRight Arrow Icon
b. Write a MATLAB function that computes the coefficients of the polynomial that is the derivative of the input polynomial. Function should be of the form: diffPolyCoeff = polyDerivative ( polyCoeff) You cannot use the inbuilt MATLAB function polyder function diffPolyCoeff = polyDerivative (polyCoeff) % Finds the derivative of the input polynomial given by vector polyCoeff.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

AE202 Problem Set 2 Solutions - AE202 Problem Set 2: MATLAB...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online