one two three four

7 ビュー (過去 30 日間)
James Knight
James Knight 2019 年 11 月 7 日
コメント済み: Rena Berman 2019 年 12 月 12 日
I have two strings stored in a variable
EG
A='HELLO'
B='TEST'
I want to repeat B to make it the same length as A
EG
A='HELLOWORLD'
B='TESTTESTTE'
  3 件のコメント
Guillaume
Guillaume 2019 年 11 月 7 日
If Thorsten hadn't posted an answer, I was going to close the question as it's a duplicate of https://www.mathworks.com/matlabcentral/answers/489791-repeat-the-value-of-a-variable-to-match-the-length-of-another-variable
Please don't waste people time by asking the same question twice.
Rena Berman
Rena Berman 2019 年 12 月 12 日
(Answers Dev) Restored edit

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

採用された回答

Thorsten
Thorsten 2019 年 11 月 7 日
Replicate B such that is is as long or longer than A, then cut it to the length of A;
B = repmat(B, 1, ceil(numel(A)/numel(B)));
B = B(1:numel(A));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by