To create a function in MATLAB that accepts two scalar inputs and returns a vector counting from a to b, you can use the following code:
main.m61 chars4 linesHere's how the code works:
countVector and two input arguments a and b.a to b is created using the : operator.' is then applied to the range to convert it into a column vector.output.end keyword.You can call this function by providing the values for a and b:
main.m42 chars3 lines
This will output the vector [1; 2; 3; 4; 5], which counts from 1 to 5.
gistlibby LogSnag