Write a function called makemat that will receive two row vectors as input argum
ID: 3566595 • Letter: W
Question
Write a function called makemat that will receive two row vectors as input arguments, and from them create and return a matrix with two rows. You may not assume that the length of the vectors is known. Also, the vectors may be of different lengths. If that is the case, add 0s to the end of one vector first, that is pad it, to make it as long as the other. For example, a call to the function might be:
>> thismat = makemat([1:5], [2:9])
thismat =
1 2 3 4 5 0 0 0
2 3 4 5 6 7 8 9
>> thismat = makemat([2:6], [1:3])
thismat =
2 3 4 5 6
1 2 3 0 0
>> thismat = makemat([2:6], [10:14])
thismat =
2 3 4 5 6
10 11 12 13 14
Explanation / Answer
clear all
clc
size1=randi([1 10])
a=randi([1 10],1,size1);
size2=randi([1 10])
b=randi([1 10],1,size2);
makemat(a,b);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.