MATLAB: Create a character cell in ascending order cell arraycell arraysstructures i want to create a cell of 1000*1 , containing the strings in ascending order. Let's say variable1, variable2,….variable999,variable1000. How can i do that with for loop? Best Answer With loop:for i =1:1000 {sprintf('variable%d',i)} % if you remove { } it's string arrayendWithout loop:compose('variable%d',(1:1000).') % cell arraycompose("variable%d",(1:1000).') % string array Related SolutionsMATLAB: Find unique or duplicate cells in cell array of chars A = {{'A', 'B', 'C'}, {'C', 'D', 'E'}, {'A', 'B', 'C'}, {'C', 'B', 'A'}}N = arrayfun(@(k) sum(arrayfun(@(j) isequal(A{k}, A{j}), 1:numel(A))), 1:numel(A))unique_elements = A(N==1)duplicated_elements = A(N>1) MATLAB: Ascending table column labels Use the compose function (R2016b and later versions): colnames = compose("Cycle %d", 1:size(matrix,2));Alternatively, use the sprintfc (undocumented) function: colnames = sprintfc("Cycle %d", 1:size(matrix,2));No loop necessary. Related QuestionManipulation of a cell array-Cell array of nested cellsAscending order-room modesHow to concatenate 2 cell arrays containing stringsI want to ascend cellDelete empty [] {1×7 cell} {1×2 cell}Merging Arrays in Ascending Order
Best Answer