Clear Filters
Clear Filters

Argument to dynamic structure reference must evaluate to a valid field name Error occurs when using properties

9 views (last 30 days)
I am trying to use transfer my functional script into App Designer to make it function as a GUI. First thing I did was define all the variables in properties that are going to be used and modified between callbacks:
properties (Access = private)
RTD = cell(5,3);TC = cell(5,3);
end
In my script each cell of RTD is a 5999x9 table, and I am able to referrence the following without errors:
RTD{1,1}.(1)
RTD{1,1}.(1)(1)
But since I made RTD a property in App Designer this causes the error message: "Argument to dynamic structure reference must evaluate to a valid field name":
app.RTD{1,1}.(1)
app.RTD{1,1}.(1)(1)
In the App Designer, I must reference the property RTD as app.RTD.
Does anyone know why this happens and how I could fix it? My only idea would be to make a local variable equal to RTD within the function callback that I need to use RTD in, and then once I am done modifying it, make app.RTD equal to the local variable.

Answers (1)

Bora Eryilmaz
Bora Eryilmaz on 2 Feb 2023
Looks like you might be trying to access the content of RTD before populating its cells with the right table content first.
% This works OK.
RTD = cell(5,3);
RTD{1,1} = array2table(rand(10,3));
RTD{1,1}.(1)
ans = 10×1
0.0727 0.7871 0.6981 0.6895 0.7415 0.3404 0.9245 0.7131 0.6452 0.6807
% Errors out since the table content is not assigned into the cell array.
RTD = cell(5,3);
RTD{1,1}.(1)
Argument to dynamic structure reference must evaluate to a valid field name.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!