Read from and make new based on positions
    6 次查看(过去 30 天)
  
       显示 更早的评论
    
I would like to go through a matrix which looks like this:

the numbers stand for ascii values
where there is capital letter means a word ends.
I read this matrix from a file, 
Then I would like to make a new matrix where I register where in this matrix I have the capital words.
So far I know to read from a matrix I would need a for loop such as:
for i=size(S)
    %here I would like to make a new matrxi based on the positons of the
    %capital words in S matrix
    if S(i,j)>=65 || S(i,j)<=90
        % here M would form
    end
end
but what I actually would like to make out of the S, which is the matrix read from the file and shown above, 
is to make a new matrix, say M, which has registerted where I have capital letters in S. 
Then M will look like 
M=(4    5
      5    7
      5   10
      2    12)
because for example  S(4,5) has 87 which stands for the capital letter W.
Questions in background to think about could be:
how can I read from S and make M? 
How can I find the positions and use them making a new matrix. If it helps the attached file contains the matrix.
0 个评论
采纳的回答
  Ive J
      
 2021-10-16
        Why not this?
G = [0	115	0	0	0	0	0	0	0	0	111	0	0
0	0	110	0	0	0	110	0	0	0	0	82	0
0	0	0	111	0	0	0	111	0	0	0	0	0
0	0	0	0	87	114	0	0	114	0	0	0	0
0	0	0	0	0	0	84	0	0	84	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0];
idx = G >= 65 & G <= 90;
[r, c] = find(idx);
M = [r, c]
更多回答(0 个)
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

