addpath('C:\Users\Buff\Documents\SJSU\Course related\ME 30\Example Code') Matrices A = [1 2 3; 4,5,6; 7 8 9] size(A) A(1,2) A(4,2) = 13 A(4,2) = 13; B=[sin(pi/4), -2^3, size(A,1)] C = 1 : 0.25 : 2 D = 0 : 5 E = linspace(0,5,3) F = logspace(1,3,5) A = [ A ; [ 10 11 12 ] ] G = A(1:3, 1:2) H = [1:4; linspace(10,40,4); 400:-100:100] I = H( [1 2], : ) J = H( : ) K=zeros(3) L=ones(4) M=eye(3) N=L*7 O=N+eye(4) P=B*E P=B*E� Q=A+B Q=B+E [1 2]*[3 ; 4] R = [1 -1 -1; 0 0 10e3; 0 10e3 0]; V = [0 10 10]�; I = R \ V v1 = [3 2 -5] v2 = [2 -4 10] sum = v1 .* v2 function rmsout = rms(v) % rms(v) root mean square of the elements of the column vector v % Function rms(v) returns the root mean square of the elements % of the column vector, v. If v is a matrix, then rms(v) returns % a row vector such that each element is the root mean square %of the elements in the corresponding column of v. vs = v.^2; % what does this line do? Also note semicolon. s = size(v); % what does this line do? rmsout=sqrt(sum(vs,1)/s(1)); % what is s(1)? v=sin([0: 0.0001*pi: 2*pi]') Lecture14 length(ones(1,3)) size(zeros(2,3)) G=[2 4 6; 8 10 12] G(2,3) G(: , 2) G(4) G(1,1)=0 G(1, :)=0 H=1:9 I=reshape(H,3,3) I = I� J=I(3:-1:1,:) K=I(:, 3:-1:1) L = reshape(I(9:-1:1),3,3) L=ones(1,5) M=ones(1,4) N = 2*L N � 1 O = [ 1:5 ] O + M L * O L* O� L .* O distances=[120, 213, 87, 35] times=[ 2, 3.8, 0.9, 0.6] speeds=distances ./ times max_speed=max(speeds) [max_speed, i] = max(speeds) R=[1 -1 1; 0 0 10e3; 0 10e3 0] eq1 = [ 1 -1 1] eq2 = [0 0 10e3] eq3 = [0 10e3 0] R = [eq1; eq2; eq3] V = [0 10 10]� I = R \ V v1=[3 2 -5] v2=[2 -4 10] sum(v1.*v2) function [z] = dot_prod(v1, v2) % dot_prod(v1,v2) computes the vector dot product between vectors v1 and v2 % Function dot_prod(v1,v2) computes and returns the vector dot product between vectors v1 and v2 z = sum(v1.*v2); A = [ 1 2 3 ]; B = [ 4 5 6 ]; % what should A dot B result in? A_dot_B = dot_prod(A,B) load ('PDXprecip.dat') % must be in search path! type file_io_example.m file_io_example % to run multi_plot.m