Create a matrix using Unix command in Matlab!
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi jan, I am using Unix command in matlab to get bunch of columns which I will be manupulating subsequently. I was manage to use awk command to have output of R like 1x21 char and which looks like (14151617181920) instead I want it in a cell. I tried using cellstr in it but didn't get much success. Ultimately I want to collpase all the columns 14,15,16,17,18,19,20 by taking mean across the columns. Can you please help me in this?
댓글 수: 1
Jan
2012년 5월 7일
Do you mean me? If so, I do not understand the question. What "bunch of columns" do you get? To which type of variable do you want to convert the string '14151617181920'? Would SSCANF be helpful? What does "not much success" explicitly mean? Please post your code and the error message, if you get one.
답변 (2개)
Walter Roberson
2012년 5월 7일
Please command
double(R)
and look for entries that are not in the range 48 to 57. 48 corresponds to '0', 49 to '1', up to 57 corresponding to '9'. Look for 32 (space), 13 (carriage return), 10 (line feed). If those other characters are present, they are important to separating the parts.
If those characters are not present, then you probably have a problem in the awk code. awk is not really an appropriate topic here, but if the awk code is relatively short, perhaps someone will happen to understand it. (perl has a stronger tie to MATLAB than awk does.)
댓글 수: 0
Jan
2012년 5월 7일
I guess that you want to convert the string '14151617181920' to the vector [14, 15, 16, 17, 18, 19, 20].
R = '14151617181920';
V = sscanf(R, '%2d');
meanV = mean(V);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!