Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to make a char using many letters instead 3

1 回表示 (過去 30 日間)
Niki
Niki 2014 年 9 月 15 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi,
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';
'Mar';
'Apr';
'May';
'Jun';
'Jul';
'Aug';
'Sep';
'Oct';
'Nov';
'Dec'];

回答 (2 件)

Star Strider
Star Strider 2014 年 9 月 15 日
Use a cell array to store strings with different lengths:
Methods = {'January'; 'February'; 'March'; 'April'; 'May'; 'June'; 'July'; 'August'; 'September'; 'October'; 'November'; 'December'};
  2 件のコメント
Niki
Niki 2014 年 9 月 15 日
unfortunately I need to be in char array since I am doing anova two [p,t,stats]= anova2(X, methods, 'off') and then multicomparion test [c,m,h,nms] = multcompare(stats);
It does not work.
Star Strider
Star Strider 2014 年 9 月 15 日
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 2014 年 9 月 15 日
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!

Translated by