Recitation 06 Problems- Solutions

Recitation 06 Problems- Solutions - 14:440:127-...

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

View Full Document Right Arrow Icon
14:440:127- Introduction to Computers for Engineers Problems for students to attempt in Recitation 6- Solutions 1. x = [1 2 3 4 5] and y = [1.23 9.76 14.74 18.28 21.03] Figure out the equation that best conveys the relationship between y and x. (Hint: use semilogx, semilogy, loglog plots and see which one looks like a straight line) x = [1 2 3 4 5]; y = [1.23 9.76 14.74 18.28 21.03]; subplot(2,2,1); plot(x,y); subplot(2,2,2); semilogx(x,y); subplot(2,2,3); semilogy(x,y); subplot(2,2,4); loglog(x,y); % semilogx looks straight c = polyfit(log(x),y,1) % c returns [12.3 1.23] % so the equation is y = 12.3log(x) + 1.23 2. x = [1 2 3 4 5] and y = [28.86 640.57 14200 316000 7010000] Figure out the equation that best conveys the relationship between y and x. (Hint: use semilogx, semilogy, loglog plots and see which one looks like a straight line) x = [1 2 3 4 5]; y = [28.86 640.57 14200 316000 7010000] subplot(2,2,1); plot(x,y); subplot(2,2,2); semilogx(x,y); subplot(2,2,3); semilogy(x,y); subplot(2,2,4); loglog(x,y); % semilogy looks straight c = polyfit(x,log(y),1) % c returns [3.1 0.26] exp(c(2)) % returns 1.3 % so the equation is y = 1.3*exp(3.1*x) 3. x = [1 2 3 4 5] and y = [7.10 18.74 33.05 49.45 67.58] Figure out the equation that best conveys the relationship between y and x. (Hint: use semilogx, semilogy, loglog plots and see which one looks like a straight line) x = [1 2 3 4 5]; y = [7.10 18.74 33.05 49.45 67.58] subplot(2,2,1); plot(x,y); subplot(2,2,2); semilogx(x,y); subplot(2,2,3); semilogy(x,y); subplot(2,2,4); loglog(x,y); % loglog looks straight c = polyfit(log(x),log(y),1) % c returns [1.4 1.96] exp(c(2)) % returns 7.1 % so the equation is y = 7.1*x^(1.4) 4. Generate a 4x4 matrix of random numbers in each of the following ranges:
Background image of page 1

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

View Full DocumentRight Arrow Icon
a) decimals [0,2] x = 2*rand(4); b) decimals [15, 25] x = 10*rand(4) + 15;
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 / 6

Recitation 06 Problems- Solutions - 14:440:127-...

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