Adding two strings same row size
1 次查看(过去 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 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!