Delete single values from a structure field
1 次查看(过去 30 天)
显示 更早的评论
Hello there,
I'm a newbie in Matlab, so please bare with me.
My problem: I have one structure array, with several fields each of different length. Each array contains values which can range between -1000 and 7000. (it's data from an experimental setup with so and so many repetitions, and each repetition gives me a different number of datapoints. I save the results from each repetition in a new field.)
I want to delete the values below zero in each field. But I just don't know how to do it; how to delete just specific elements from a field instead of the whole thing? Please help?! Thanks!
0 个评论
回答(2 个)
Sean de Wolski
2011-6-8
One way, assuming ALL fields need to have this applied:
structfun(@(x)x(x>=0),your_struct,'uni',false);
Welcome to MATLAB Answers!
2 个评论
Walter Roberson
2012-3-5
Loop over fieldnames() of the structure and use dynamic field names (if those are supported.)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!