Kinarm | Interactive Robotics Brain Injury Research

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

Mobile nav

What are persistent variables?

What are persistent variables?

Posted on Jan 23, 2018

DWQA Questions › Category: Custom Task Development › What are persistent variables?
0 Vote Up Vote Down
Koloman Varady Staff asked 3 years ago

What are persistent variables? How do I use them and what is an example of their use?

1 Answers
0 Vote Up Vote Down
Koloman Varady Staff answered 3 years ago

Persistent variables in a function will preserve their state between function calls. For Simulink, this means that the values will be preserved from one time-step to the next. An example of using a persistent variable is storing a target’s position so you can change it dynamically throughout a task.

To use a persistent variable, you need to define it as persistent and you need to initialize it. Care must be taken to initialize it to the correct size (i.e. the size that it will be used in that function). The isempty(x) function can be used to check whether the variable x is initialized, and if it is not initialized, then you can use that opportunity to set the persistent variable to an initial value. In this way, you can make sure that the variable is initialized when the task is loaded and only initialized once.

For example, if x needs to be a persistent 2×10 array, then the following code will define it as persistent, and initialize it to the correct size:

persistent x;

if isempty(x)
x = zeros(2,10);
end

Note: you cannot pass in a variable (e.g. from the task protocol tables) to initialize the persistent variable. The initialization requires a constant value for initial value because input variables are not always available when the task is first loaded.

Ian Brown Staff replied 3 years ago

For an example Task Program that uses persistent variables, please see the Visuomotor Rotation task that is available for download as a Sample Custom Task

Support

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

Questions about Kinarm products?

Please feel free to contact us, we’d be happy to help.

Contact Us

Dexterit-E Explorer

View any Dexterit-E exam file. FREE to Download!

Learn More

KST Summary

Our Kinarm Standard Tests enable clinical researchers to perform precise neurological assessment.

Learn More

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
  • Installing & Maintaining Your Kinarm Lab
  • User Guides & Documentation
  • Software Downloads
  • Creating Custom Tasks
  • Sample Custom Tasks
  • Training Videos
  • 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
  • Login
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.