ee231_ass2_sol - Numerical Analysis for Electrical and...

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

View Full Document Right Arrow Icon
EE 231_B1 Numerical Analysis for Electrical and Computer Engineers Course Instructor: Dr. Sergiy Vorobyov - 1 - Solutions to Assignment 2 3.3 The M-file can be written as function annualpayment(P, i, n) nn = 1:n; A = P*i*(1+i).^nn./((1+i).^nn-1); y = [nn;A]; fprintf('\n year annual payment\n'); fprintf('%5d %14.2f\n',y); This function can be used to evaluate the test case, >> annualpayment(55000,.066,5) 2.1 >> q0 = 12;R = 50;L = 5;C = 1e-4; >> t = linspace(0,.7); >> q = q0*exp(-R*t/(2*L)).*cos(sqrt(1/(L*C)-(R/(2*L))^2)*t); >> plot(t,q)
Background image of page 1

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

View Full DocumentRight Arrow Icon
EE 231_B1
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Numerical Analysis for Electrical and Computer Engineers Course Instructor: Dr. Sergiy Vorobyov - 2 - year annual payment 1 58630.00 2 30251.49 3 20804.86 4 16091.17 5 13270.64 3.14 The following function implements the piecewise function: function v = vpiece(t) if t<0 v = 0; elseif t<10 v = 11*t^2 - 5*t; elseif t<20 v = 1100 - 5*t; elseif t<30 v = 50*t + 2*(t - 20)^2; else v = 1520*exp(-0.2*(t-30)); end Here is a script that uses vpiece to generate the plot k=0; for i = -5:.5:50 k=k+1; t(k)=i; v(k)=vpiece(t(k)); end plot(t,v)...
View Full Document

This note was uploaded on 12/20/2010 for the course E E 231 taught by Professor Vorobyov during the Spring '10 term at University of Alberta.

Page1 / 2

ee231_ass2_sol - Numerical Analysis for Electrical and...

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

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