フィルターのクリア

combine number from cell array and letter to a string

4 ビュー (過去 30 日間)
Dongyan Zhu
Dongyan Zhu 2021 年 6 月 18 日
コメント済み: Dongyan Zhu 2021 年 6 月 18 日
Now I have a cell array contaning some numbers:
SequencePreview =
1×3 cell array
{'3'} {'1'} {'4'}
Then I want to get a string showed using for loop as below:
'V3-V1-V4'
Does someone have an idea? Thank you!

採用された回答

Stephen23
Stephen23 2021 年 6 月 18 日
編集済み: Stephen23 2021 年 6 月 18 日
C = {'3','1','4'}
C = 1×3 cell array
{'3'} {'1'} {'4'}
S = join(strcat("V",C),"-") % output = string
S = "V3-V1-V4"
or the old-fashioned way:
S = sprintf('-V%s',C{:}); % output = char
S = S(2:end)
S = 'V3-V1-V4'
  1 件のコメント
Dongyan Zhu
Dongyan Zhu 2021 年 6 月 18 日
Thank you for the answer!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by