필터 지우기
필터 지우기

Passing a dynamic property name to its own get method

조회 수: 7 (최근 30일)
Philip M
Philip M 2021년 5월 3일
답변: Philip M 2021년 5월 3일
I have a class to which I would like to add the dynamic property "Volume". When I call class.Volume, I want it to execute a get method that includes the string "Volume" as an input argument. Likewise, I would like it to behave the same way for any given property name, i.e. if I add the property "Density" and call class.Density, I want it to call the same function but with "Density" as an argument. Function handles are confusing and I can't figure out if this is even possible.

채택된 답변

Philip M
Philip M 2021년 5월 3일
I found the answer here:
https://www.mathworks.com/matlabcentral/answers/48831-set-methods-for-dynamic-properties-with-unknown-names

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by