Was struct2array removed from MATLAB?

조회 수: 157(최근 30일)
Mark Lepage
Mark Lepage 2022년 5월 12일
댓글: dpb 2022년 5월 12일
I am using a newish program, but I am getting the error:
Unrecognized function or variable 'struct2array'.
I remember using this in the past, but appears to longer be a part of MATLAB?


dpb 2022년 5월 12일
편집: dpb 2022년 5월 12일
struct2cell seems to be lowest level still extant, yes. <struct2array#answer_403725> gives some history(*) of its evolution from the Signal Processing Toolbox to main product to now apparently red-haired stepchild.
I suppose that since a struct isn't required to be directly convertible to an array given the different field content possible, TMW decided it wasn't a generally-enough-applicable function to keep so they abandoned it.
(*) I don't know when I've used it, if ever; I also tend to avoid struct when can, generally using the table for heterogenous data instead, so hadn't ever noticed anything about it.
I'm still using R2020b here; there it is still extant, but the doc page is just the help text one-liner. I dunno, that may have been the extent always on that...
>> which -all struct2array
>> which -all struct2cell
built-in (C:\ML_R2020b\toolbox\matlab\datatypes\@struct\struct2cell) % struct method
All struct2array is is the catenation of the output from struct2cell into an array -- which may/may not always work...
>> type struct2array
function a = struct2array(s)
%STRUCT2ARRAY Convert structure with doubles to an array.
...dpb snip...
% Convert structure to cell
c = struct2cell(s);
% Construct an array
a = [c{:}];
  댓글 수: 2
dpb 2022년 5월 12일
I didn't think to try with the current online facility, but searched the documentation instead, Steven. It appears undocumented other than the internal help line would still display I suppose.
This may always have been the case in that it was apparently built for some specialized purpose for the toolboxees and so never widely considred as "real" functionality but somewhat above being made private.
It's got to be a mess trying to keep all the myriad of such little specialty tools in synch and not duplicate them unnecessarily; hence the shared location it would appear.

댓글을 달려면 로그인하십시오.




Community Treasure Hunt

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

Start Hunting!

Translated by