how to create a dynamically changing in size column vector?

2 vues (au cours des 30 derniers jours)
Leonardo Wayne
Leonardo Wayne le 4 Mar 2016
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.

Réponses (1)

Walter Roberson
Walter Roberson le 4 Mar 2016
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.

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by