This challenge activity uses a 3rd party app Though your act
This challenge activity uses a 3rd party app. Though your activity may be recorded, a refresh may be required to update the banner to the left. Write a for loop to populate multiplication Table with the multiples of base Value from 0 to 5. Ex: If base Value is 2. Then multiplication Table is [0, 2, 4, 6, 8, 10]. (2Times0 =0, 2 Times 1=2, 2Times2 = 4. 2 Times 3 = 6. 2 Times 4 = 8. 2 Times 5 = 10) function multiplication Table = Create Table(base Value) % Multiples of base Value used to populate multiplication Table multiplication Table = zeros(lf 6); % Preallocate multiplication Table with 6 elements % Write a for loop to populate multiplication Table with the % multiples of base Value from theta to 5
Solution
MATLAB FUNCTION
function multiplicationTable = CreateTable( baseValue )
% Multiples of baseValue used to populate multiplicationTable
multiplicationTable = zeros(1,6); % Parallocate multiplicationTable with 6 elements
for i = 0:5 % loop to populate multiplicationTable
multiplicationTable(i+1) = i*baseValue;
end
end
OUTPUT
>> CreateTable(2)
ans =
0 2 4 6 8 10
>> CreateTable(5)
ans =
0 5 10 15 20 25
