Any fixes for 'undefined function or variable 'struct2array'?
230 views (last 30 days)
Hi there! I'm using CHAP for pupillometry preprocessing, and can't seem to find a workaround for the below. Any tips or tricks out there? Deeply appreciated!
'Undefined function or variable 'struct2array'.
Error in chap>show_analyze_window (line 340)
data_table(i,:) = [outliers.(char(comp_names(i))) num_of_valid_trials int32(struct2array(ploted_data.(char(comp_names(i))).events))];
Error in chap>start_analyze (line 136)
data = show_analyze_window(src, cond_mat_cleaned, cond_events, data);
Error while evaluating UIControl Callback.
Walter Roberson on 28 Nov 2019
struct2array() is undocumented. In R2019b it is part of an archive named shared_measure_common
In https://www.mathworks.com/matlabcentral/answers/357399-conversion-of-structure-to-double-in-r2017a#comment_485767 I recorded that,
In versions up to R2013a, struct2array was part of the Signal Processing Toolbox and was installed in toolbox/signal/sigtools/struct2array.m . it was moved into basic MATLAB in R2013b and was installed in toolbox/shared/measure/struct2array.m . I find it in every version of MATLAB I have installed, including all the beta versions I have loaded.
If you are stuck you can find an implementation at https://git.dynare.org/Dynare/dynare/blob/2dcaff4f162dbadb1ca9dadb7fc0e61557af74e5/matlab/missing/struct2array/struct2array.m but I would suggest that first you try
restoredefaultpath; rehash toolboxcache
if that works, then you can proceed to save the path -- but note that this will remove any third-party toolboxes from your path (and possibly support packages as well.)