(MATLAB) Please, help!! I\'ve completed part (a) of the script, but I\'m not sur
ID: 3885898 • Letter: #
Question
(MATLAB) Please, help!! I've completed part (a) of the script, but I'm not sure how to continue in step (b). Thank you!
2. 20 pts Create a script for Multiplication of two Matrices 1 (dimensions m × n) and M2 (dimensions-n x p), and gives you back M3 (dimensions n × p). M3 = M1 * M2 (a) Ask the user for the values of the matrix (b) Implement a fool-proof conditions such that the dimensions are feasible for matrix multiplication, i.e. m × p = (m × n) * (n × p) (c) The command zeros is a MATLAB function that makes a matrix with all values equal to zero. For example, zeros (2,3) returns a 2-by-3 matrix with all elements equal to zeroExplanation / Answer
m = input("Enter ist dimension of M1 matrix ");
n = input("Enter 2nd dimension of M1 matrix ");
o = input("Enter ist dimension of M2 matrix ");
p = input("Enter 2nd dimension of M2 matrix ");
M1 = zeros(m,n);
M2 = zeros(o,p);
if(n==o)
print("ENter elements of matrix M1");
for(i=1:m)
for(j=1:n)
M1(i,j) = input("Enter element ");
end
end
print("ENter elements of matrix M2");
for(k=1:o)
for(l=1:p)
M2(k,l) = input("Enter element ");
end
end
%M1 = input("Enter elements of matrix M1 ");
%M2 = input("ENter elements of matrix M2 ");
M3 = M1*M2;
M3
else
print("Not feasible");
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.