How to concatenate a string with elements from an array

1 回表示 (過去 30 日間)
Gian Carpinelli
Gian Carpinelli 2018 年 4 月 10 日
回答済み: Walter Roberson 2018 年 4 月 10 日
Hey so as the title says I want to create a string with elements from three different (column) vectors. E.g.
strcat('T(i,1)', 'P(i,1)', 'num2str(P(i,1))')
however this is only giving me the actual T(i,1)... etc as the print, any way go actually get the content of the cell, e.g. T(1,1) = 'hello' - get this hello text.
cheers

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 4 月 10 日
sprintf('%s P(%d,1) %d', T{i,1}, i, P(i,1))
I had to guess about what you are trying to output; since you convert P(i,1) from number to string it would not make sense to also put it in the middle part, so I figure you must be wanting to put in the literal 'P(' and ',1)' but with the actual index shown.

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by