This question is closed. Reopen it to edit or answer.

how to make a char using many letters instead 3

3 views (last 30 days)
Niki on 15 Sep 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
Currently I am facing a problem in which I would like to generate a char array with many letters in each, For example instead only using Feb, I want to use the full name, somebody knows how to do it?
Methods = ['Febrary';

Answers (2)

Star Strider
Star Strider on 15 Sep 2014
Use a cell array to store strings with different lengths:
Methods = {'January'; 'February'; 'March'; 'April'; 'May'; 'June'; 'July'; 'August'; 'September'; 'October'; 'November'; 'December'};
Star Strider
Star Strider on 15 Sep 2014
Did you use the cell array and did it give an error? If not, experiment with it to see if it works.
I don’t follow exactly what you are doing or how you are using the array, but if you look under ‘Examples’ -> ‘> Multiple Comparison of Material Strength’, you can see that the example uses a cell array for the alloy variable.

Robert Cumming
Robert Cumming on 15 Sep 2014
The best solution is to use cell arrays, but if you need it all in a single matrix it needs to be square.
Every row (month) has to be the same length (number of columns). You do that by preallocating your matrix with spaces and then fill the months in.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!