Conversion of structure to double in R2017a

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

>> 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?
I have T as structured file which have 580*9 table format, earlier I could use the same syntax but now it says Undefined function or variable 'struct2array'.
[Marenaweather1213] = struct2array(T);% converting structured file to double array
? 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)
class(T)
ans =
'struct'
size(T)
ans =
1 1
as far as Walter's response, we go the T from matfile.
>> [Marenaweather1213] = struct2array(T);% converting structured file to double array
Undefined function or variable 'struct2array'.
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'
I have .mat file and we used function to get the data out of it in structure format.
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')
I got this error
which('struct2array') 'struct2array' not found.
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.
In 2016a, it was there. I recently upgraded to 2017a, now it is acting weird. I do not know what should I do here, I want to convert structure file to double array file.
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.
@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?

Sign in to comment.

Answers (0)

Categories

Asked:

on 19 Sep 2017

Commented:

Jan
on 19 Sep 2017

Community Treasure Hunt

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

Start Hunting!