Exercise 2-New
Exercise 2-New
Q3. Write a Matlab function that will take into two matrices A,B and will output a matrix of the
same size where
C(i,j)=max{A(i,j),B(i,j)}
function C = elementwise_max(A, B)
% Check if the input matrices have the same size
if ~isequal(size(A), size(B))
error('Input matrices must have the same size.');
end
Q2. Write a Matlab program that will take a matrix from user input and display all elements of
the matrix that are larger than 3.
Ans.
A=input(‘matrix:’)
dimension=size(A);
[row column]=size(A);
for i=1:row
for j=1:column
If A(i,j)>3
Disp(A)
end
end
end