function a1sol %insert the exact file name (as explained in the submission % instructions) after "function" %------------------------------------------------------------------------ %%% ENGINEERING MATHEMATICS III - MATH 2Z03 %%% ASSIGNMENT #1 %%% HOMEWORK \#1: INTRODUCTION TO MATLAB %------------------------------------------------------------------------ %------------------------------------------------------------------------ % Covers: % - "Numerical Mathematics" by M. Grasselli and D. Pelinovsky, % Sections 1.1-1.6 % - "Advanced Engineering Mathematics" by D.G. Zill and W.S. Wright, % (Jones and Bartlett, 4th edition) Section 2.2 %------------------------------------------------------------------------ %------------------------------------------------------------------------ % Instructions: % - Submit your assignment electronically (via Email) to the % address specific to your lab section as indicated on the course % website; hardcopy submissions will not be accepted. % - It is obligatory to use the current MATLAB template file available at % http://www.math.mcmaster.ca/gabardo/M2Z03/frames/template.m; % submissions non compliant with this template will not be accepted. % - Make sure to enter your name and student I.D. number in the % appropriate section of the template. % - Late submissions and submissions which do not comply with % these guidelines will not be accepted. % - All graphs should contain suitable titles and legends. %------------------------------------------------------------------------ % Written by Vladislav Bukshtynov, 2009 clc; close all; clear all; % Student information disp(' ------------ Student Information ------------ ') % Please enter your information here Name = 'Johny'; Surname = 'Good'; ID = 123456789; fprintf(' Student: %s %s (ID: %d) \n', Name, Surname, ID); disp(' ------------------------------------------------ ') disp(' ') disp(' ') disp(' ') disp(' ') disp(' ---------- Solution to Question #1 ---------- ') disp(' ') % Insert here your solution to Question #1 % (if you define your own functions, they may appear % at the end of the file) A=[6,7; 8, 9]; Answer1=matcos(A) Answer2=matsin(A) Answer3=(matcos(A))^2+(matsin(A))^2 disp(' ') disp(' ------------------------------------------------ ') disp(' ') disp(' ') disp(' ') disp(' ') disp(' ---------- Solution to Question #2 ---------- ') disp(' ') % Insert here your solution to Question #2 % (if you define your own functions, they may appear % at the end of the file) x=[-0.5:0.01:0.5]; y1=0.*x; y2=asin(sqrt(3)/2*sqrt(x.^2+1)); y3=pi-asin(sqrt(3)/2*sqrt(x.^2+1)); y4=pi*ones(size(x));; figure plot(x,y1,x,y2,x,y3, x,y4); xlabel('x'); ylabel('y'); grid on; disp(' ') disp(' ------------------------------------------------ ') disp(' ') disp(' ') disp(' ') disp(' ') disp(' ---------- Answers ---------- ') disp(' ') % DO NOT TOUCH THIS PART (RESERVED FOR THE INSTRUCTOR'S USE) Name Surname ID Answer1 Answer2 Answer3 function T=matcos(A) T=0; k=0; while max(max(abs(A^(2*k)./factorial(2*k)))) >=0.01 T=T+(-1)^(k).*A^(2*k)./factorial(2*k); k=k+1 end function T=matsin(A) T=0; k=0; while max(max(abs(A^(2*k+1)./factorial(2*k+1)))) >=0.01 T=T+(-1)^(k).*A^(2*k+1)./factorial(2*k+1); k=k+1 end