To make a list in MATLAB, you can use arrays. There are two types of arrays in MATLAB: row arrays and column arrays.
To create a row array, you can use square brackets to enclose the elements of the array, separated by spaces or commas. For example:
main.m22 chars2 lines
This creates a row array called myList
with elements 1, 2, 3, 4, 5.
To create a column array, you can use semicolons to separate the elements of the array. For example:
main.m26 chars2 lines
This creates a column array called myList
with elements 1, 2, 3, 4, 5.
You can also create arrays using the linspace
and logspace
functions. The linspace
function creates an array with equally spaced values between two endpoints, while the logspace
function creates an array with logarithmically spaced values between two endpoints.
For example, to create an array of 10 equally spaced values between 1 and 5:
main.m29 chars2 lines
And to create an array of 10 logarithmically spaced values between 1 and 100:
main.m29 chars2 lines
gistlibby LogSnag