pra_shant_shah asked . 2021-12-24

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

 

data import , struct

Expert Answer

John Williams answered . 2024-05-19 18:29:26

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.

 

 

 

s = struct(field,value) creates a structure array with the specified field and value. The value input argument can be any data type, such as a numeric, logical, character, or cell array.

  • If value is not a cell array, or if value is a scalar cell array, then s is a scalar structure. For instance, s = struct('a',[1 2 3]) creates a 1-by-1 structure, where s.a = [1 2 3].

  • If value is a nonscalar cell array, then s is a structure array with the same dimensions as value. Each element of s contains the corresponding element of value. For example, s = struct('x',{'a','b'}) returns s(1).x = 'a' and s(2).x = 'b'.

  • If value is an empty cell array {}, then s is an empty (0-by-0) structure.


Not satisfied with the answer ?? ASK NOW

Frequently Asked Questions

MATLAB offers tools for real-time AI applications, including Simulink for modeling and simulation. It can be used for developing algorithms and control systems for autonomous vehicles, robots, and other real-time AI systems.

MATLAB Online™ provides access to MATLAB® from your web browser. With MATLAB Online, your files are stored on MATLAB Drive™ and are available wherever you go. MATLAB Drive Connector synchronizes your files between your computers and MATLAB Online, providing offline access and eliminating the need to manually upload or download files. You can also run your files from the convenience of your smartphone or tablet by connecting to MathWorks® Cloud through the MATLAB Mobile™ app.

Yes, MATLAB provides tools and frameworks for deep learning, including the Deep Learning Toolbox. You can use MATLAB for tasks like building and training neural networks, image classification, and natural language processing.

MATLAB and Python are both popular choices for AI development. MATLAB is known for its ease of use in mathematical computations and its extensive toolbox for AI and machine learning. Python, on the other hand, has a vast ecosystem of libraries like TensorFlow and PyTorch. The choice depends on your preferences and project requirements.

You can find support, discussion forums, and a community of MATLAB users on the MATLAB website, Matlansolutions forums, and other AI-related online communities. Remember that MATLAB's capabilities in AI and machine learning continue to evolve, so staying updated with the latest features and resources is essential for effective AI development using MATLAB.

Without any hesitation the answer to this question is NO. The service we offer is 100% legal, legitimate and won't make you a cheater. Read and discover exactly what an essay writing service is and how when used correctly, is a valuable teaching aid and no more akin to cheating than a tutor's 'model essay' or the many published essay guides available from your local book shop. You should use the work as a reference and should not hand over the exact copy of it.

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.