I have an array that I want to basically capture as text so I can write it to one cell of an Excel file as a column header. It's a range of subjects, and I'll have some data underneath. So the range is:
range = 2:12;
which creates and array, but I want the Excel file header to just read 2:12. I've tried creating another variable to capture this text in one field, using num2str like this:
rangeChar = num2str(range);
and I get:
rangeChar = 2 3 4 5 6 7 8 9 10 11 12
but they are each separate fields, so when exported to Excel they each take up their own cell. The original range is not always sequential - for example I might have
range = cat(2, 2:4, 8, 9:12);
so I can't just do a
rangeChar = sprintf('%d:%d', range(1), range(end));
type of thing either. Any thoughts?
range = cat(2, 2:4, 8, 9:12)?