index rows containing specific value

Hello everyone
I've a cell 352X79. The first row contains the marker names. The first column contains the filenames.
Now i need to find all the NaN values and write the row containing the NaN to a new variable X, so I have all colums with NaN values in one variable.
Or is it even possible to get the filename and the names of the NaN marker into the new variable? So it woul look like X(1,1) = filname, X(1,2) = markar_Name etc.
Thanks for your help!

4 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 3 月 26 日
Can you provide a small example with expected result?
Oliver Kumar
Oliver Kumar 2016 年 3 月 26 日
編集済み: Oliver Kumar 2016 年 3 月 26 日
result(1,:) = {'VPN' 'marker1' ' marker2'} result(2,:) = {test_vpn, 5, NaN} result(3,:) = {test_vpn2, 1, 0}
Now I want to get the row with the NaN to a new cell callend NaN.
Even better would be to get the Name of the VPN and the Name of the marker into a new variable. --> newVariabel = {'test_vpn', 'marker2'}
it could also happen, that ther are more then one missing marker.
Thanks for your help
Stephen23
Stephen23 2016 年 3 月 26 日
"I've a cell 352X79. The first row contains the marker names. The first column contains the filenames."
You would be much better off using a table.
Alternatively you could use a simple numeric array and two cell arrays (See my answer).
Oliver Kumar
Oliver Kumar 2016 年 3 月 26 日
Hi Stephen
Ok, I have all the nummeric data also as a matrix. Column 1 has the numbers for marker1, Column2 for marker2, etc. So I could build a table out of that data. And I have a Cell with all the VPN.
What would be the next step after I've build the table? Thank you!

サインインしてコメントする。

 採用された回答

Stephen23
Stephen23 2016 年 3 月 26 日
編集済み: Stephen23 2016 年 3 月 26 日

0 投票

Using a cell array is a total waste of MATLAB's abilites for processing numeric arrays quickly and efficiently. You would be much better off storing the data in three arrays (col-names, row-names, numeric data), or (even better) in a table. Whatever method you use for processing a cell array of mixed data is going to be much more complicated that if you simply stored your numeric data in a numeric array.
Here is an example showing how simple this task can be when the data is stored in a simple numeric array:
colC = {'marker1',' marker2'};
rowC = {'testvpn1','testvpn2','testvpn3'};
mat = [5,NaN;1,0;6,NaN] % your data
[idxR,idxC] = find(isnan(mat))
[colC(idxC),rowC(idxR)]

1 件のコメント

Oliver Kumar
Oliver Kumar 2016 年 3 月 26 日
編集済み: Oliver Kumar 2016 年 3 月 26 日
hey, thanks a lot! I just changed the last line to [rowC(idxR);colC(idxC)], so I geht my VPN names in the first row.
colC = marker'; rowC = filenames_all'; mat = how_many_NaNs; [idxR,idxC] = find(isnan(mat)); NaN_mark = [rowC(idxR);colC(idxC)];
Now I get the error: Index exceeds matrix dimensions.
Error in NaN_marker (line 5) NaN_mark = [rowC(idxR);colC(idxC)]
I think because there are sometimes more then one NaN values for one filename.
The code worked if there is only one NaN value.
idxR and idxC are 215x1
Edit: It works! Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

質問済み:

2016 年 3 月 26 日

編集済み:

2016 年 3 月 26 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by