question archive Develop a MATLAB program to create matrix MATH, considering the following: 11
Subject:StatisticsPrice:9.82 Bought3
Develop a MATLAB program to create matrix MATH, considering the following: 11.5t ROW ELEMENTS:
lstterm— 1; last term — ll; spacing 2 2"" HOW ELEMENTS: 1|.?t term— CI: last term — 25: spacing 5 3"" HOW
ELEMENTS: il.St term— it); last term — ED; number of elements —6
Our MATA matrix generator function should be able to generate the following:
>> myMATAGen
ans =
1 3 5 7 9 11
0 5 10 15 20 25
10 0 0 0 0 60
The following code would be able to achieve the result:
%****************************************************************************
%
% Function Name: myMATAGen()
%
% Parameters: None
%
% Description: Generates a matrix with the following criteria:
% 1st Row Elements: 1st term - 1; last term - 11; spacing 2
% 2nd Row Elements: 1st term - 0; last term - 25; spacing 5
% 3rd Row Elements: 1st term - 10; last term - 60; number of
% elements - 6.
function MATA = myMATAGen()
% Generate an initial function
MATA = zeros(3,6); % Represents 3 Rows and 6 elements per row
MATA(1,:) = 1:2:11;
MATA(2,:) = 0:5:25;
MATA(3,1) = 10;
MATA(3,6) = 60;
end
Step-by-step explanation
Below is an explanation of each line of code of the MATA matrix generator program:
Line 1
MATA = zeros(3,6); % Represents 3 Rows and 6 elements per row
Line 2
MATA(1,:) = 1:2:11;
Line 3
MATA(2,:) = 0:5:25;
Line 4
MATA(3,1) = 10;
Line 5
MATA(3,6) = 60;