Conversion from struct type to array

Hey I have a .mat file which contains ECG data.Where aa contains struct type [15x10000 double]. How can I convert aa into [somethingx1 double] so that I can calculate length of ECG signal ?
aa=load('ff.mat');
aa

4 个评论

This question is quite unclear.
In MATLAB struct is a common name for data of class struct , but it seems you are actually talking about a data of class double , not struct. Or do you have a struct containing some numeric data? If so, why don't you tell us something useful about the struct, such as its dimensions and the field names and what they contain?
You write that you want to calculate the length of the signal, but you have already written the length in the question: 15x10000. So if 10000 is the length of the signal, what else do you want to know? Or are you using another definition of length? Have you tried using size ?
Perhaps you are simply trying to extract some data from this double array: have you tried using MATLAB's rather powerful indexing options?
Because we cannot read minds or your computer screen, we have to rely on your description of the data and your objective working with it. Currently this is not adequate to know how to help you.
Yes I have a struct contains numeric data field name val which has 15 row and 10000 column.As I have loaded ECG signal so it must contain voltage with respect to time. But in mat file which I loaded variable contains struct type 15x10000 (data type double) where I can not understand what value contains in row or column such like time or voltage.As I am working on ECG data so I want to store this in 2D array which contains in row time and in column voltage(somethingx1). How can I do this ? (Here I attach my mat file)
I have found it and it is working thanks. :)
fahim ,please what code you apply to find the 2D representtaion of your ecg signle, i have the same issue

请先登录,再进行评论。

 采纳的回答

So I saved your uploaded .mat file, and load-ed its contents into my workspace like this:
load('ff.mat')
It turns out that this .mat file contains no structure, only a single variable named val, which is of class double, and has size 15x10000. You request "I want to store this in array", but it already is an array, and a very convenient double array at that. You want a numeric array of data, and you already have one single perfect array of numeric data within that .mat file.
Your statement "I can not understand what value contains in row or column such like time or voltage" is possibly quite true, but do suppose that anyone here on MATLAB Answers can magically know how your data is arranged? To know exactly what the data contains you will have to ask the person who created it, or read their documentation, or perhaps engage in a little bit of reverse engineering of the function that saved that data.
For a start it seems likely that the second dimension is time, although personally I could not find any strictly monotonically increasing values in any one row:
>> all(diff(val)>0,2)
ans =
0
0
0
0
0
0
0
0
0
0
0
0
0
0
So it seems that some kind of time variable is not included in this data. In any case, I would highly recommend that you work through these tutorials:

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by