solution4 - % Assignment 4 % Prob. 1 A=[7 3 4 5;2 9 5 8;3 6...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % Assignment 4 % Prob. 1 A=[7 3 4 5;2 9 5 8;3 6 1 9]; B=[6 3 9 5;4 8 5 3;1 9 7 2]; disp('A+B') A+B disp('A-B') A-B disp('A.*B') A.*B disp('A./B') A./B disp('A.^B') A.^B disp('A+4') A+4 disp('2*A') 2*A A+B ans = 13 6 4 A-B ans = 1 -2 2 A.*B ans = 42 8 3 A./B ans = 1.1667 0.5 3 A.^B ans = 117649 16 3 A+4 ans = 11 6 7 2*A ans = 7 13 10 8 9 5 9 12 13 27 43046721 10077696 262144 3125 1 3125 512 81 1 1.125 0.66667 0.44444 1 0.14286 1 2.6667 4.5 9 72 54 36 25 7 25 24 18 0 1 -3 -5 0 -6 0 5 7 6 17 15 13 10 8 10 11 11 14 4 6 6 18 12 % Prob. 2 8 10 2 10 16 18 disp('sum(A)') sum(A) disp(' ') disp('cumsum(A)') cumsum(A) disp(' ') sum(A) ans = 12 cumsum(A) ans = 7 9 12 3 12 18 % Prob. 3 n=1:5; summation=sum((n.^2-1)./n) disp(' ') 18 10 22 4 9 10 5 13 22 summation = 12.717 % Prob. 4 disp('method using sum') nn=1:20; xx=0:0.1:0.5; [x,n]=meshgrid(xx,nn); summation=sum(cos(n.*x)./(n.^2+1)) disp(' ') disp('method not using sum') disp(' ') n=1:20; x=0:0.1:0.5; summation=(1./(n.^2+1))*cos(n'*x) disp(' ') method using sum summation = 1.0279 0.94401 0.78649 0.66685 0.56494 0.45657 method not using sum summation = 1.0279 % Prob. 5 nn=1:10; xx=0:0.1:0.5; [x,n]=meshgrid(xx,nn); summation=sum((1./n).*exp(-(n*pi/2).^2).*cos((pi/2)*n.*x)); SOL=1-xx+(4/pi^2)*summation 0.94401 0.78649 0.66685 0.56494 0.45657 SOL = 1.0344 0.93396 0.8327 0.73063 0.62781 0.5243 ...
View Full Document

Page1 / 4

solution4 - % Assignment 4 % Prob. 1 A=[7 3 4 5;2 9 5 8;3 6...

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

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