Kinarm | Interactive Robotics Brain Injury Research

  • Products
  • Clinical Applications
  • News
  • Support
  • About Us
  • Contact

Mobile nav

Loading matrix into statefow

Loading matrix into statefow

Posted on Aug 14, 2019

DWQA Questions › Category: Custom Task Development › Loading matrix into statefow
0 Vote Up Vote Down
Peter Holland asked 4 years ago

Hi, I am trying to set up a task in which on some trials we guide the hand along a predetermined trajectory (similar to a channel trial but with a more complex curved trajectory). In order to do this I would like to load a ‘library’ of trajectories from a .mat file (for example a 50×1000 matrix). I have tried using the coder.load function to make sure the matrix is loaded at compilation-time rather than run-time but I get a CPU overload (Maximum TET exceeded). This happens whether I load the data in the initialize block within the stateflow or using a simulink block and loading it there and passing it as input to the stateflow.  I’ve also tried the horrible hack version of printing the values of the matrix into a .m file as a function and calling that directly. Is there any way you can think of to accomplish this? Maybe somewhere in the model configuration options? The size of the matrix existing in stateflow is not the problem as we initialize it to full size and can perform processing steps on it, it seems to be getting the data from another source that’s the issue. Thanks for your help!

Question Tags: loading data
1 Answers
0 Vote Up Vote Down
Koloman Varady Staff answered 4 years ago

Hi Peter,
Probably what is happening is that, as it is being passed into Stateflow, the matrix has to be copied over and, once the C code is generated, that is a nested for loop with 50 x 1000 iterations.

My first thought is to look at whether you need the whole matrix at once. If not, you can just pass bits of the trajectory at a time.

Another thing you can try is to transpose the matrix to be 1000×50. This will improve your TET immediately (thought it might not be enough of a gain). MATLAB is a column major language https://en.wikipedia.org/wiki/Row-_and_column-major_order and it will be faster to traverse a matrix by going down the columns rather than across rows.

An alternative is you can write your own C to do this, rather than rely on the generated C and include that file among those generated (that’s a more complicated thing to do but quite possible).

You could also contact Mathworks support and see if they have any ideas.
Cheers,
Koloman

Support

  • User Guides & Documentation
  • Software Downloads
  • Install/Maintain Your KINARM Lab
  • Training Videos
  • New User Training
  • Creating Custom Tasks
  • Sample Custom Tasks
  • Q&A Forum
  • Publications by Research Area

Products

  • Platform Comparison
  • Kinarm Exoskeleton Lab
  • Kinarm End-Point Lab
  • Kinarm Standard Tests
  • Dexterit-E
  • Dexterit-E Explorer
  • NHP Kinarm Exoskeleton Lab

Clinical Applications

  • Clinical Applications
    • Stroke and TIA
    • Traumatic Brain Injury (TBI)
    • Neurological Disease
    • Pediatric
    • Primarily Non-Neurological
  • Clinical Research Sites
  • Publications

News

  • Kinarm News
  • Events
    • Neuroscience
    • Kinarm Camp
  • Product Notices
  • @KinarmLab Twitter Feed
  • Open Jobs

Support

  • Kinarm Help & Support
  • User Guides & Documentation
  • Software Downloads
  • Installing & Maintaining Your Kinarm Lab
  • Training Videos
  • New User Training
  • Creating Custom Tasks
  • Sample Custom Tasks
  • Q&A Forum

About Us

  • About Us
  • Our People
  • Quality
  • Supplier Requirements
  • End-User License Agreement
  • Intellectual Property
  • Privacy & Terms

Contact

  • Contact Kinarm
    • International Sales Agents
  • Request an Account
footer-logo

140 Railway St. Kingston, ON K7K 2L9 Canada Toll Free: (888) 533-4393 Phone: (613) 507-4393 info@kinarm.com

© Copyright BKIN Technologies. All Rights Reserved

Quality | Privacy Policy | Web design/development by 1dea Design + Media Inc.