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에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!