how to make a list in matlab in matlab

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.m
myList = [1 2 3 4 5];
22 chars
2 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.m
myList = [1; 2; 3; 4; 5];
26 chars
2 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.m
myList = linspace(1, 5, 10);
29 chars
2 lines

And to create an array of 10 logarithmically spaced values between 1 and 100:

main.m
myList = logspace(0, 2, 10);
29 chars
2 lines

related categories

gistlibby LogSnag