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
Ket [755]
3 years ago
6

Write a function M-file that takes as input two matrices A and B, and as output produces the product by columns of the two matri

x. For instance, if A is 3 × 4 and B is 4 × 5, the product is given by the matrix C = [A*B(:,1), A*B(:,2), A*B(:,3), A*B(:,4), A*B(:,5)] THIS CONTENT IS PROTECTED AND MAY NOT BE SHARED, UPLOADED, SOLD OR DISTRIBUTED 2019 v8 [email protected] School of Mathematical and Statistical Sciences, Arizona State University 8 The function file should work for any dimension of A and B and it should perform a check to see if the dimensions match (Hint: use a for loop to define each column of C). Call the file columnproduct.m. Test your function on a random 5×2 matrix A and a random 2×4 matrix B . Compare the output with A*B. Repeat with 4 × 5 and 5 × 2 matrices and with 4 × 5 and 2 × 5 matrices. Use the command rand to generate the random matrices for testing. Include in your lab report the function M-file and the output obtained by running it.

Engineering
1 answer:
docker41 [41]3 years ago
7 0

Answer:

Here is the code in Matlab for the function.

I have also attached the m file for function as well as the test run of the code  here and screenshot of the result.

Code:

function [ C ] = columnproduct( A, B )

% get the dimesnions of A

sizeA = size(A);

sizeB = size(B);

% check if columns of A are same as rows of B

if(sizeA(2) ~= sizeB(1))

   error('matrix dimensions do not match')

end

% initialize resultant matrix

C = [];

for i = 1:sizeB(2)

   % concatenating product of matrix A with each column of B

   C = [C A*B(:,i)];

end

end

You might be interested in
Determine the following for a south facing surface at 30� slope in
lesantik [10]

Answer:

z=60.32°, i=0.32°, Beam Radiation = 1097.2 W/m²,  Id = 94.2 W/m², Ir=14.1W/m², total radiation = 1205.4 W/m², Local time=1:21PM

Explanation:

A. Zenith Angle:

As we know that,

Zenith angle=z=90⁰-α=L(latitude)=29.68⁰

Another way to do it is to find α first,

At solar time hour angle is 0⁰. So, solar altitude becomes equal to latitude which could be written as

sinα=cosL

α=sin⁻¹(cosL)=sin⁻¹(cos29.68⁰)=60.32°

B. Angle of incidence:

angle of incidence= cosi=sin(α+β)=sin(60.32°+32°)=sin92.32°

i=cos⁻¹(sin92.32°)=0.32°

C. Beam Radiation:

First we need to calculate extra terrestrial radiations

Iext.=1353[1+0.034cos(360n/365)]

where n=264

=1345 W/m²

Now,

Beam Radiation=CIext⁻ⁿ

where n=0.1/sin60.32°

Beam Radiation = 1097.2 W/m²

D. Diffude Radiation:

difuse radiation = Id = 0.0921ₙcos²(β/2)

where β=30°

Id = 94.2 W/m²

E. Reflected Radiations:

Ir=pIn(sinα+0.092)sin²(β/2)

= (0.2)(1097.1)(sin60.32+0.092)sin²(30/2)

= 14.1W/m²

F. Total Radiation:

total radiation = beam radiation + diffuse radiation + reflected raddiation

= 1205.4 W/m²

G. Local Time:

LST= ST-ET-(lₓ-l(local))4min/₀

     = 12:00-7.9min-(75°-82.27°)4min/₀

     =12:21PM

Local time

LDT=LST+=12:21+1:00=1:21PM

5 0
3 years ago
Future solution for air pollution in new zealand
andrezito [222]

Answer:

New Zealand may use some of these solutions to prevent air pollution

Explanation:

Using public transports.

Recycle and Reuse

No to plastic bags

Reduction of forest fires and smoking

Use of fans instead of Air Conditioner

Use filters for chimneys

Avoid usage of crackers

5 0
3 years ago
Which of the following elements would make a good insulator?
Ainat [17]

Answer:

Glass

Explanation:

Please mark me the brilliant

8 0
2 years ago
What is a perpetual motion machine of the second kind?
d1i1m1o1n [39]

Answer:

perpetual motion machine of second type is a machine that generates job from a single source of heat.

Explanation:

perpetual motion machine is a machine that generates job from a single source of heat. only one heat reservoir is present in this type of machine and it is continuously cooled to generate function without transferring heat to a cooler reservoir. Such a demonstration machine was names as ammonia engine

5 0
3 years ago
These waveforms are applied to a gated D latch, which is initially RESET. Which of the areas identified on the Q waveform is inc
Andrej [43]

Question Completion with Options:

A) Area a B) Area b C) Area c D) Area d

Answer:

The incorrect waveform identified on the Q waveform is the:

C) Area c.

Explanation:

Area c is the incorrect waveform because its output is not correct.  The Q waveform indicates that the electrical forces project toward the negative pole of the lead axis.  A gated D latch is a flip flop latch with an additional control input, which determines when to change the state of the circuit. Most times, this control unit is a clock input or an enable input.

8 0
3 years ago
Other questions:
  • 1. At the end of the day, a bakery gives everything that is unsold to food banks for the needy. If it has 12 apple pies left at
    14·1 answer
  • Compare a series circuit powered by six 1.5-volt batteries to a series circuit powered by a single 9-volt battery. Make sure the
    6·1 answer
  • A heat engine that receives heat from a furnace at 1200°C and rejects waste heat to a river at 20°C has a thermal efficiency of
    14·1 answer
  • Develop an E-R model (E-R Diagram) for the application belowDatabase RequirementsLogin
    12·1 answer
  • A cylindrical metal specimen having an original diameter of 12.8 mm (0.505 in.) and gauge length of 50.80 mm (2.000 in.) is pull
    9·1 answer
  • Weight limit for a pallet
    15·2 answers
  • what advantage might there be to having the encoder located on the motor side of the gearhead instead of at the output shaft of
    7·1 answer
  • I think it’s a wedge. Am I right?
    8·2 answers
  • In a rack and pinion steering system, what component protects other
    11·2 answers
  • The on-board computer controls the suspension system based on inputs from?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!