%Exercise 1 - Differentiation %There is no initial Declaration or any

advertisement
%Exercise 1 - Differentiation
%There is no initial Declaration or any include required for Matlab
%programing. Any variables used will be automatically declared by Matlab
x=0:0.1:3;
F = ((cos(x)).*(exp(2.*x)).*(x.^3))
%setting the range of x
z = gradient(F)
%using the built in library to find the slope of function F
plot(x,z,x,F)
grid on
%To plot the graph of differential F from 0 to 3
%Turning on the grid in the Plot Figure
%Exercise 2 - Matrices
%There is no initial Declaration or any include required for Matlab
%programing. Any variables used will be automatically declared by Matlab
clc;
clear;
%Clear the Command Window
%Clear all the previous saved data
m=input('Enter number of rows : ');
n=input('Enter number of colums : ');
fprintf('\nEnter the element values for Matrix A\n');
for i = 1:m
for j = 1:n
fprintf('Enter element for A[%d,%d] : ',i,j);
A(i,j) = input('');
end
end
A
name
%output the text, same as cout
%using 'for' loop,
%to end the 'for' loop
%to display back the Matric A, just put its
%WITHOUT SEMICOLON at the end
fprintf('\n\nEnter the element values for Matrix B\n');
for i = 1:m
for j = 1:n
fprintf('Enter element for B[%d,%d] : ',i,j);
B(i,j) = input('');
end
end
B
end
fprintf('\n\nC = AxB\n');
C=A*B
fprintf('\n\nThe Determinant of Matrix C is : ');
D=det(C)
%same for Matric B, WITHOUT semicolon at the
%directly Multiply Matrix A to Matrix B
%Use the Matlab built in function
%library to calculate the Determinant
if (D==0)
fprintf('\n\nMatrix C cannot be inversed\n');
else
fprintf('\n\nThe inverse of Matrix C is : ');
I=inv(C)
end
%Use the Matlab built in function
%library to find the Inverse
Download