1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mina [271]
3 years ago
8

Write a function M-file that takes as input two matrices A and B, and as output produces

Computers and Technology
1 answer:
s344n2d4d5 [400]3 years ago
4 0

Answer:

Explanation:

The Matlab Function rowproduct.m

function C = rowproduct( A,B) % The function rowproduct.m

M = size(A); % Getting the dimension of matrix A

N = size(B); % Getting the dimension of matrix B

if(M(2)~=N(1)) % Checking the dimension

fprintf('Error in matrix dimension\n'); % print error if dimension mismatch

return; % And end the further execution of function

end % End of if condition

C = []; % initilizing the result matrix C

for k = 1:M(1) % Loop to perform the row product

C = [C;A(k,:)*B];% Computing row product and updating matrix C

end % End of loop

end % End of function

Testing the function rowproduct.m

The 2x3, 3x2 Matrix:

>> A = [ 1 2 3; 1 2 3];

>> B = [1 2; 1 2; 1 2];

>> C = rowproduct(A,B)

C =

6 12

6 12

>> A*B

ans =

6 12

6 12

The 3x4, 4x2 matrix:

>> A = [ 1 2 3 4; 1 2 3 4; 1 2 3 4];

>> B = [1 2; 1 2; 1 2; 1 2];

>> C = rowproduct(A,B)

C =

10 20

10 20

10 20

>> A*B

ans =

10 20

10 20

10 20

The 3x4 and 2x4 matrix:

>> A = [ 1 2 3 4; 1 2 3 4; 1 2 3 4];

>> B = [1 2 1 2; 1 2 1 2];

>> rowproduct(A,B)

Error in matrix dimension

You might be interested in
Why is it essential for every person living in the 21st century to have a computer​
Zolol [24]

Answer: because computers are our main source of communicating and where we find a wide range of information to help us

Explanation:

4 0
3 years ago
Is "all swans are white" a statement
katovenus [111]
Umm I'm pretty sure that is a statement, correct me if in wrong
7 0
3 years ago
Write a program that asks the user to enter a positive integer that represents a number in the decimal system and then displays
Maru [420]

Answer:

In Python:

def decimalToBinary(num):

   if num == 0:

       return 0

   else:

       return(num%2 + 10*decimalToBinary(int(num//2)))

       

decimal_number = int(input("Decimal Number: "))

print("Decimal: "+str(decimalToBinary(decimal_number)))

Explanation:

This defines the function

def decimalToBinary(num):

If num is 0, this returns 0

<em>    if num == 0: </em>

<em>        return 0 </em>

If otherwise

   else:

num is divided by 2, the remainder is saved and the result is recursively passed to the function; this is done until the binary representation is gotten

       return(num%2 + 10*decimalToBinary(int(num//2)))

       

The main begins here.

This prompts the user for decimal number

decimal_number = int(input("Decimal Number: "))

This calls the function and prints the binary representation

print("Decimal: "+str(decimalToBinary(decimal_number)))

3 0
3 years ago
if we declare a function as friend of a template class will it be a friend for a particular data type or for all data types of t
suter [353]

Answer:

When we declare a function as a friend of a template class, it means it can access the public, as well as the private and protected members both data variables, and functions of that class. Thus, the friend has access not only to certain data types, but they have access to all the data types of that class. Thus, the function declared as the friend is never deprived of accessing any particular data type of a template class, or any class.

Explanation:

However, you should understand what is template class as well. A template class is the one that is a template and can be transformed into various object code for various data types, that supports all the operators used inside that class or function. We do have the template function. And these behave generically.

7 0
3 years ago
Brainly Question 2.0
Klio2033 [76]

Answer:

Depends, but most of the time definitly  

:)

3 0
3 years ago
Other questions:
  • A programmer wrote the program below. The program uses a list of numbers called numList. The program is intended to display the
    7·1 answer
  • If a computer is found to have an ip address of 169.254.1.1, what can you assume about how it received that ip address?
    11·1 answer
  • John would like to move from the city into the suburbs and has been saving up a large down payment for a home. Which is the most
    7·1 answer
  • Given two variables firstInClass and secondInClass which have already been associated with values, write code which swaps the va
    9·1 answer
  • Shanice wants to make her résumé. Which of these is a recommended practice for her?
    5·1 answer
  • At Chicago Cubs games, residents across the street from Wrigley Field can watch the game from their apartment windows. Many of t
    14·1 answer
  • What is the benefit of making an archive folder visible in the Outlook folder list?
    6·1 answer
  • PLS HELP ME!! WILL GIVE BRAINLIEST
    7·2 answers
  • Write a program to find the principle amount​
    10·1 answer
  • True or False? Popular sites are always mean accurate
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!