Text and Number in a Matrix/row
4 ビュー (過去 30 日間)
古いコメントを表示
Dhirendu Somani
2021 年 1 月 26 日
コメント済み: Dhirendu Somani
2021 年 1 月 30 日
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/501213/image.png)
I want to create a row which include both numbers and text.
Sample Code
%%%% Input %%%%%%%
Text : {'x1=','y1=','z1='}
Nos : [1:1:3];
% Sample Code
for i=1:length(Nos)
Row(1,i) = Text(i);
Row(1,i+1) = Nos(i);
end
% Need Output as below
Row = [ x1=1 y1=2 z1=3 ]; % (numbers and text in alternate columns )
% Attached image for needed output
5 件のコメント
Mathieu NOE
2021 年 1 月 28 日
hello
would it be just one line as the format you showed or dou you intend to have column oriented vectors for x1, y1, z1 ?
if yes maybe you should put those three labels as header line in the first row and then store the vectors below (my 2 cents)
採用された回答
Walter Roberson
2021 年 1 月 28 日
Text = {'x1=','y1=','z1='}
Nos = [1:1:3]
Noscell = num2cell(Nos)
Output = reshape([Text(:).'; Noscell(:).'], 1, [])
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!