close all; clear all; % This code is a part of a first introduction in Matlab % test of commands for, while % -- compute a vector y with n first i^3 terms n = 10; y = []; for i = 1:n y = [y,i^3] end % -- compute and display the smallest nonnegative integer n such that 2^m>= a: a = 100; m = 0; while 2^m < a m = m + 1; end m % Define matrix A = [ 1 2 3; 4 5 6; 7 8 9]; rref(A) c = [1; 2; 7]; r = [2 4 6]; d = r*A; d % find the eigenvalues of A D=eig(A); D %[V,D]; % Define - Plot functions x = -2.0:.01:2.0; y = exp(-x.^2); figure (1); plot(x,y) x=0:.01:2*pi; y1=sin(x); y2=sin(2*x); y3=sin(4*x); figure (2); plot(x,y1,'--',x,y2,':',x,y3,'+') x = [0:10]/10; f1 = sin(x); f2 = x.^2; f3 = ( x.*f1 )./(1 + 3*f2); figure (3); plot (x, f3); xlabel('x'); ylabel('f3'); figure(4); hold on; g = 1./(1+x.^2); h = -1./(1+x.^2) plot (x, g,'r'); plot (x, h,'b'); xlabel('x'); ylabel('f3'); hold off; figure(5); g = 1./(1+x.^2); h = -1./(1+x.^2) plot(x,g,'r',x,h,'b'); xlabel('x'); ylabel('g,h');