how to create a dynamically changing in size column vector?
5 ビュー (過去 30 日間)
古いコメントを表示
if I wanted to create a column vector and want to fill each vector element with characters that are not the same size for example: signalname = ['Torque';'Torque1'] How to I make signalname change in size to accommodate any element size.
note: error is; Dimensions of matrices being concatenated are not consistent.
0 件のコメント
回答 (1 件)
Walter Roberson
2016 年 3 月 4 日
signalname = {'Torque';'Torque1'};
This will give you a column vector of cells. Each of the cells will contain a row vector of characters (that is, a string.) You would access the content with signalname{i} instead of signalname(i)
Another possibility is
signalname = char({'Torque';'Torque1'});
This will give you a 2 x 7 char array in which you accessed signalname(i,:) to get the content. Each row in which the original content was shorter than the longest line will be blank padded, so you may wish to use strtrim(). Note that this does not satisfy your requirement that a vector be used.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!