Accessing Specific Data Field In Ground Truth Data

2 ビュー (過去 30 日間)
Matpar
Matpar 2020 年 4 月 20 日
コメント済み: Matpar 2020 年 5 月 5 日
Hi All,
I have my goundtruth .mat file with some fields empty and I am trying to select data from only the rows and colums that contains data in all four fields!!
I am not certain how to start the code but i am guessing this is a for loop or rather a while loop!!
Here,s my take on this but it is wrong, I am learning and some day I will get this but I need to understand how to start this!
This is my code
Fullfields= 0;
while SDataTable(:,:) == []
Fullfields = (Fullfields + 1)
end
disp(Fullfields);
Can someone help me please!
Please see image of my task!
  2 件のコメント
Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2020 年 4 月 23 日
Hey!
Can you share that .mat file with us? That would certainly help in arriving at a solution faster.
Matpar
Matpar 2020 年 4 月 23 日
Hi Vinai Datta Thatiparthi and thanx in advance for responding,
I am tryin to automate this process by selecting data from the fields that is highlighted by the red arrows only!
The matfile is attached and thank you in advance once more!

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

回答 (1 件)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2020 年 4 月 23 日
Hey!
This should work -
data = load('Shooting.mat');
vals = data.Shooting.LabelData;
% Use cellfun to identify which elements within the timetable are empty
idx = all(~cellfun(@isempty,vals{:,:}),2);
% variable 'out' will contain only those rows which have all non-empty values
out = vals(idx,:)
Here's the Doc link for cellfun.
Hope this helps!
  3 件のコメント
Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2020 年 4 月 24 日
Hey!
The MATLAB function cellfun works on cell arrays. However, the data that we're working with (vals) is of type timetable.
Using
vals{:,:}
would expand its contents and result in all the cell arrays within the timetable vals.
Secondly, you can mention the dim argument in the function all. This specificies the dimension along which you want the operation to happen. In this case, I want to check if in every row within vals, all elements are equal to 1, and that is why I mentioned '2' as the dimension. Therefore, giving a value of 5 would not work and will result in an error.
Hope this helps!
Matpar
Matpar 2020 年 5 月 5 日
Thanx it really did! thank you loads, multi_tasking sorry for the later response

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

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by