Answer :
Explanation:
In Matlab, we can create a function that constructs a row array countValues from 0 to 25, with elements incremented by a incrementValue, this can be done in two ways;
If the value of IncrementValue is hard-coded than it will only work for IncrementValue=5, on the other hand, if the value of IncrementValue is not hard-coded than we can call CreateArray() with different IncrementValue.
1. Increment Value is hard-coded
function countValues = createArray(IncrementValue)
IncrementValue = 5;
countValues = 0:IncrementValue:25;
disp(countValues)
end
Output:
CreateArray(5)
ans = 0 5 10 15 20 25
2. Increment Value is not hard-coded
function countValues = createArray(IncrementValue)
countValues = 0:IncrementValue:25;
disp(countValues)
end
Output:
CreateArray(5)
ans = 0 5 10 15 20 25
CreateArray(2)
ans = 0 2 4 6 8 10 12 14 16 18 20 22 24
CreateArray(10)
ans = 0 10 20