HW2 - Kacie Cruz PGE 310 kc23367 1.a....

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: Kacie Cruz PGE 310 kc23367 1.a. >> b=[30:-3:0] b = 30 27 24 21 18 15 12 9 6 3 1.b. >> a=logspace(0,10,5) a = 1.0e+010 * 0.0000 0.0000 0.0000 0.0032 1.0000 1.c. >> A=[-2 1 4 2;1 -8 2 5;4 -1 3 2;3 -4 3 -0] A =-2 1 4 2 1 -8 2 5 4 -1 3 2 3 -4 3 1.d. >> B=7*rand(4,4)-5 % Another way of writing this: B=7*rand(4)-5 B =-3.0615 -0.1362 -1.9288 -3.6919-4.6768 -2.7803 -2.3291 -1.5716-4.3201 1.6516 0.3586 -1.8809 0.7642 -4.7589 0.5664 -0.4758 1.e. >> F=3.5*ones(4,4) % Also could have written F=3.5*ones(4) F = 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 3.5000 1.f. >> C=A*B C =-14.3056 -5.4194 4.0958 -2.6631 29.5337 1.6150 20.2532 2.7405-19.0012 -2.3276 -3.1774 -19.7902-3.4376 15.6673 4.6058 -10.4318 1.g. >> D=A./B D = 0.6533 -7.3422 -2.0738 -0.5417-0.2138 2.8774 -0.8587 -3.1814-0.9259 -0.6055 8.3655 -1.0633 3.9256 0.8405 5.2966 Kacie Cruz PGE 310 kc23367 1.h. >> D(:,2)=[2 -1 2 5] D = 0.6533 2.0000 -2.0738 -0.5417-0.2138 -1.0000 -0.8587 -3.1814-0.9259 2.0000 8.3655 -1.0633 3.9256 5.0000 5.2966 1.i. >> D(2,2)=B(1,3) D = 0.6533 2.0000 -2.0738 -0.5417-0.2138 -1.9288 -0.8587 -3.1814-0.9259 2.0000 8.3655 -1.0633 3.9256 5.0000 5.2966 1.j. >> E=reshape(D,[2 8]) % Again: E=reshape(D,2,8) E = Columns 1 through 7 0.6533 -0.9259 2.0000 2.0000 -2.0738 8.3655 -0.5417-0.2138 3.9256 -1.9288 5.0000 -0.8587 5.2966 -3.1814 Column 8-1.0633 1.k. >> [Rows, Columns]=size(E) Rows = 2 Columns = 8 1.l. >> x=B(:,3) x =-1.9288-2.3291 0.3586 0.5664 1.m. >> u=[-1;3;0;2] , b=A*u % Also works: u=[-1,3,0,2] , b=A*u' u =-1 3 2 b = 9-15 Kacie Cruz PGE 310 kc23367-3-15 1.n. >>Ab=[A b]; >> save KacieCruz.txt Ab ascii 2. >> x= -5:0.5:5 x = Columns 1 through 9-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000 -1.0000 Columns 10 through 18-0.5000 0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 Columns 19 through 21 4.0000 4.5000 5.0000 >> y=x y = Columns 1 through 9-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000 -1.0000 Columns 10 through 18-0.5000 0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 Columns 19 through 21 4.0000 4.5000 5.0000 >> [X Y]=meshgrid(x,y) X = Columns 1 through 8-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4.0000 -3.5000 -3.0000 -2.5000 -2.0000 -1.5000-5.0000 -4.5000 -4....
View Full Document

Page1 / 15

HW2 - Kacie Cruz PGE 310 kc23367 1.a....

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