Question: MATLAB. I NEED TO MAKE A FUNCTION AND THEN PUT IT IN A SCRIPT.. THANKYOU ............................................................................................................................................. function [C]=matrixMulti(A,B) %% implement a matrix multiplication algorithm %

MATLAB. I NEED TO MAKE A FUNCTION AND THEN PUT IT IN A SCRIPT.. THANKYOU

.............................................................................................................................................

function [C]=matrixMulti(A,B)

%% implement a matrix multiplication algorithm

% C(i,j)=sum_over_k (A(i,k)*B(k,j), please review the slides to get familiar with

% matrix multiplication. You can access element X_ij as X(i,j) for matrix X.

% all of your code shoule be within this function.

%% to do list:

% 1. check if the # of columns of A is the same as the # of rows in B. if

% not, print an error message to the command window.

% 2. calculate C(i,j)

end

...................................................................................................................................................

% matrix multiplication

% 2/20/2018, jifutan@niu.edu

clear;clc;

MA=[1 2;3 4]; % matrix MA. Make sure you understand how to use ; in matrix

MB=[1 2 3;4 5 6]; % matrix MB

MC=[1 1;2 2;3 3]; % matrix MC.

%% call matrixMulti function to calcuate the product of MA, MB

% [C]=matrixMulti(A,B); % you need to change the argument name such that it

% is consistent with given variables.

% put your one line code here.

%% check your solution with matlab built in operator *. Does C you get from

% function matrixMulti match with MA*MB? How do you do that?

% put your one line code here.

%% call matrixMulti function to calcuate the product of MA, MC

% [C]=matrixMulti(A,B); % you need to change the argument name and output name

% such that it is consistent with given variables, or it is not overwritten

% existing variables.

% put your one line code here.

%% call matrixMulti function to calcuate the product of LA, LB,

LA=rand(50); % search built in function rand in matlab help

LB=rand(50,100);

% [C]=matrixMulti(A,B); % you need to change the argument name and output name

% such that it is consistent with given variables, or it is not overwritten

% existing variables.

% put your one line code here.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!