I am trying to create a list of numbers of the form 1.X
where X
goes from 1
to 65
in order.
1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11, ..., 1.62, 1.63, 1.64, 1.65
I have tried the following code but not getting what I need:
v=1.1:0.1:1.65;
I end up with a list from 1.1-1.6 (only 6 numbers). I have played around with the stepping variable, where I changed it from 0.1 to 0.005, still no luck. Once I get the right number list, I would like to convert it to strings.
You can achieve that using string concatenation as
result = "1." + string((1:65).');
or more simply, exploiting implicit conversion (thanks to @Wolfie),
result = "1." + (1:65).';
This produces an array of strings. If you prefer a cell array of char vectors, just use cellstr
to convert:
result = cellstr("1." + (1:65).');