To create an array in MATLAB, you can use square brackets [ ] to define the elements of the array separated by commas or spaces. Let's see an example of creating a 1D and 2D array in MATLAB:
main.m
% Creating a 1D array a = [1, 2, 3, 4, 5]
% Creating a 2D array b = [1, 2, 3; 4, 5, 6; 7, 8, 9]
In the above example, we have created a 1D array 'a' containing the elements 1, 2, 3, 4, 5 and a 2D array 'b' having the elements 1, 2, 3 in the first row, 4, 5, 6 in the second row, and 7, 8, 9 in the third row.