In: Computer Science
Using MatLab
Write a program which will:
a. Accept two numbers from the user m and n
b. Define an array with the dimensions a(n,m) and fill it with
random numbers in the range of -100 to 100 inclusive.
c. Accept from the user two row numbers. Multiply the two rows
(element by element) and find the sum. Print the result.
d. Accept from the user two column numbers. Add the two columns
(element by element) and find the sum. Print the result.
`Hey,
Note: If you have any queries related to the answer please do comment. I would be very happy to resolve all your queries.
clc
clear all
close all
format long
m=input('Enter m: ');
n=input('Enter n: ');
A=randi([-100,100],m,n);
r1=input('Enter row1: ');
r2=input('Enter row2: ');
disp('row multiplied sum is');
sum(A(r1,:).*A(r2,:))
c1=input('Enter col1: ');
c2=input('Enter col2: ');
disp('col added sum is');
sum(A(:,c1)+A(:,c2))
Kindly revert for any queries
Thanks.