필터 지우기
필터 지우기

Delete single values from a structure field

조회 수: 1 (최근 30일)
Mary
Mary 2011년 6월 8일
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!

답변 (2개)

Sean de Wolski
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
Andreas
Andreas 2012년 3월 5일
How would you do it with Matlab Coder that does not support anonymous functions?
Walter Roberson
Walter Roberson 2012년 3월 5일
Loop over fieldnames() of the structure and use dynamic field names (if those are supported.)

댓글을 달려면 로그인하십시오.


Mary
Mary 2011년 6월 9일
Worked perfectly! Thanks so much! And thanks for the welcome. :)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by