MetaSelIndPlotPARAMS.MetaLegendHandles.(CurrSelIndType).(CurrTransMethodString).Values = [1 2 3];
,然後嘗試使用exist
:
exist('MetaSelIndPlotPARAMS.MetaLegendHandles.(CurrSelIndType).(CurrTransMethodString).Values')
它返回0
,在這裏我希望可以將輸出爲1
。
exist
似乎不使用動態字段名,因爲工作:
MetaSelIndPlotPARAMS.MetaLegendHandles.(CurrSelIndType).(CurrTransMethodString).Values
返回:
ans =
1 2 3
如何檢查在結構中的最後一個字段的存在呢?
我解決了它這樣的,但它是醜陋:) – babipsylon
'exist'是檢查變量,函數,文件夾或階層的存在。結構領域不是這些事情之一。這也不適用於明確的字段名稱。使用['isfield'](http://www.mathworks.com/help/matlab/ref/isfield.html)。 – excaza