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!