Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
hi dear's,
i create matrix like this:
A=
1.00,0.00,0.00,92,44,0.43,0.07,0.43,0.05,0.00,0.00,0.00,0.00,normal.
0.00,0.00,0.00,1.00,0.00,0.00,103,54,0.49,0.06,0.49,0.04,0.00,0.00,normal.
0.00,1.00,0.00,0.00,255,255,1.00,0.00,1.00,0.00,0.00,0.00,0.00,0.00,smurf.
0.00,0.00,255,255,1.00,0.00,1.00,0.00,0.00,0.00,0.00,0.00,smurf.
1.00,0.00,0.00,255,255,1.00,0.00,1.00,0.00,0.00,0.00,0.00,0.00,smurf.
0.00,1.00,0.00,0.00,255,254,1.00,0.01,0.00,0.00,0.00,0.00,0.00,0.00,normal.

how i can Find the row number of a matrix has a 'normal' value؟
thanks
Posted
Updated 17-Sep-14 20:54pm
Comments
Legor 17-Sep-14 9:24am    
I doubt that you create your matrice like this. First of all this isnt even MATLAB syntax and second matrices cant store different types. To store different types you have to take cell arrays: A = {1.0, 'normal'}; Also: are normal and smurf variables or strings?
[no name] 17-Sep-14 9:43am    
thanks my friend, you are right, i read a text with readtable, the data is on readtable
how i can get the row number if last column=='normal' ??

1 solution

Given that you are talking about cell arrays and you want to search for a string you can use the function strcmp()[^].

Example:
A = {1.0, 1.0, 'abc' ,3; 2.0, 3.0, 'fff', 'abc'}

A = 

    [1]    [1]    'abc'    [  3]
    [2]    [3]    'fff'    'abc'

[rows, cols] = find(strcmp('abc', A))

rows =

     1
     2


cols =

     3
     4
 
Share this answer
 
v3
Comments
[no name] 17-Sep-14 9:45am    
thanks for your answer, but i need find row number???
Legor 17-Sep-14 10:16am    
Its easy ... you just have to look for the rows that contain a 1 after. See my updated solution for one way to do this. Also consider learning the Matlab Basics before starting to work with it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900