Suppose I create a struct
data.ID0 data.ID1
Suppose I want to have a loop i that first work with data.IDO and then with data.ID1. Please advise.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 4월 29일

0 개 추천

structfun(). If the results are scalar numeric values and what you want is an array of the results, then do not use the 'uniform', 0 option. Otherwise use 'uniform', 0, which will cause a struct to be returned with fields the same as the original field names, but with content as generated by the function you specified.
Example:
structfun(@mean2, data) %mean2 always returns a scalar even for empty input
structfun(@tan, data, 'uniform', 0) %returns struct with fields ID0 and ID1 in which each value has been replaced by its tan.

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

제품

태그

질문:

2018년 4월 29일

답변:

2018년 4월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by