Read from and make new based on positions
1 view (last 30 days)
Show older comments
I would like to go through a matrix which looks like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/768996/image.png)
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 Comments
Accepted Answer
Ive J
on 16 Oct 2021
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]
More Answers (0)
See Also
Categories
Find more on Cell Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!