Adding two strings same row size
2 ビュー (過去 30 日間)
古いコメントを表示
First string presents the name of the sensors to be measured: And are separated by semicolons.
str='TC1;TC2;TC3;TC4;C1;C2;C3;C4'
Second string are 8 rows separated by str2= randi([-10,80],20,8)
I had some problems with rand and tells me the rand can’t produce a scalar,
Second problem is adding both both columns with the same length on top of each other
I would like to use join,I get the following error I don’t understand. I am running this on Matlab mobile.
totalstr=join(output_str,str2,'delimiter') Error using join (line 73) Dimension argument must be a positive integer scalar within indexing range.
1 件のコメント
Stephen23
2021 年 1 月 27 日
Bastiaan Pierik's incorrectly posted and accepted "answer" moved here:
Many thanks for all the replies! So there are two methods to do this.
回答 (2 件)
Star Strider
2021 年 1 月 24 日
str={'TC1','TC2','TC3','TC4','1','C2','C3','C4'};
str2= randi([-10,80],20,8);
T = array2table(str2, 'VariableNames',str);
That should do what you want.
4 件のコメント
Star Strider
2021 年 1 月 25 日
Thank you!
(Note — There are several join functions, such as the one I refer to in this sentence that applies to string arrays. The functions themselves determine what version of the function to use, depending on the arguments provided.)
Cris LaPierre
2021 年 1 月 24 日
What are you trying to create?
The issue is you are mixing data types in an array. I think the way would do this is to use a table.
output_str={'TC1' 'TC2' 'TC3' 'TC4' 'C1' 'C2' 'C3' 'C4'};
str2= randi([-10,80],20,8);
totalstr = array2table(str2,'VariableNames',output_str)
7 件のコメント
Cris LaPierre
2021 年 1 月 25 日
Share an example of the text file you are trying to read. Note that I am using my laptop with the full version of MATLAB, not MATLAB Mobile.
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!