create a number array of indices that starts from 1 and end at the length of % “price1”, i.e. 1, 2, 3, … n, where n is the length of “price1”. in matlab

You can use the following code to create an array of indices in MATLAB:

main.m
price1 = [10, 20, 30, 40, 50];
indices = 1:length(price1);
59 chars
3 lines

In this code, we first create an array price1 with some sample values. Then, we create another array indices that starts at 1 and ends at the length of price1 using the length function.

This will create an array indices with values [1, 2, 3, 4, 5] in this example.

related categories

gistlibby LogSnag