Add text to all rows of one column in matrix

7 ビュー (過去 30 日間)
Riccardo Rossi
Riccardo Rossi 2020 年 11 月 4 日
編集済み: Stephan 2020 年 11 月 4 日
Hi,
I have to replace the values of a column of a 4x3 matrix with a string or character as in the following example:
0 1 0.94
0 2 0.88
0 3 0.45
0 4 0.66
C50D 1 0.94
C50D 2 0.88
C50D 3 0.45
C50D 4 0.66
How can I obtain the second matrix? Thank you for your help!

回答 (1 件)

Stephan
Stephan 2020 年 11 月 4 日
編集済み: Stephan 2020 年 11 月 4 日
Use a table:
A = [0, 1, 0.94; 0, 2, 0.88; 0, 3, 0.45; 0, 4, 0.66]
b = 'C50D'
A1 = table(repmat(b,size(A,1),1),A(:,2),A(:,3))

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by