Conversion of structure to double in R2017a
Show older comments
I want to convert structure file to double array, earlier I used struc2array but since I have 2017a, these function do not work. Do anyone know what is the function?
14 Comments
Guillaume
on 19 Sep 2017
>> struct2array(struct('a', 1, 'b', 2))
ans =
1 2
>> ver
----------------------------------------------------------------------------------------------------
MATLAB Version: 9.2.0.538062 (R2017a)
Clearly, your struct2array not working has nothing to do with R2017a. Perhaps, if you showed us what exact code you're using and what exact error you're getting, we'd be able to help.
Note that struct2array has never been a documented function, so it's always been risky to use. If the data can be stored in an array why is it stored in a structure in the first place?
Kundan
on 19 Sep 2017
Walter Roberson
on 19 Sep 2017
? Do you mean that T is the result of matFile() ?
@Kundan: please post the complete error message. This means all of the red text. And also show us what these commands display:
class(T)
size(T)
Kundan
on 19 Sep 2017
Edited: Walter Roberson
on 19 Sep 2017
Kundan
on 19 Sep 2017
Edited: Walter Roberson
on 19 Sep 2017
Walter Roberson
on 19 Sep 2017
Your T cannot be the result of matfile():
>> T = matfile('DataR.mat')
T =
matlab.io.MatFile
Properties:
Properties.Source: '/Users/roberson/MATLAB/3/357/357003/DataR.mat'
Properties.Writable: false
S: [1x1 struct]
>> class(T)
ans =
'matlab.io.MatFile'
Kundan
on 19 Sep 2017
OCDER
on 19 Sep 2017
Can you try the following to see if it returns a folder path to the struct2array.m file? Perhaps the matlab path is not set correctly, leading to the error.
which('struct2array')
Kundan
on 19 Sep 2017
Walter Roberson
on 19 Sep 2017
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.
Kundan
on 19 Sep 2017
Walter Roberson
on 19 Sep 2017
Try
ls(fullfile(matlabroot, 'toolbox/shared/measure/struct2array.m'))
If that shows a file name then the file exists and it would then have to be a path problem:
rehash toolboxcache
If the file does not exist then reinstall MATLAB.
Jan
on 19 Sep 2017
@Kundan: Please note that I even do not know what a "structure file" is. The explanation "structured file which have 580*9 table format" is not clear also. According to your comment T is a "struct". But what does "table format" mean then?
What exactly does "acting weird" mean? You get a clear and short error message. Perhaps the M-file was deleted by accident?
Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!