Stateflow editor lags with long statements

I have been experiencing a painful issue within Stateflow ever since upgrading from 2014b to 2015b (and even 2016a). I have the following 16 lines of code existing within one statement along a transition between two nodes. There is nothing else in the state chart other than a default transition into the first node, then this statement along the transition to the second node. When I try to edit this statement, I notice the editor starts to lag. Any subsequent edit of this statement makes the editor lag more and more. It can take up to 20 seconds for the editor to respond to a change in cursor position.
Has anyone experienced this and/or identified a solution? I know the suggestion will be to break these lines of code into smaller, two line statements. But this is a band-aid solution. I never came across this issue in 2014b. It seems to have become worse in 2015b. I'm surprised the same problem shows up in 2016a!
% code
Offset=0;
Bytes[0] = (Switches[Offset+0] << 0) + (Switches[Offset+1] << 1) + (Switches[Offset+2] << 2) + (Switches[Offset+3] << 3) + (Switches[Offset+4] << 4) + (Switches[Offset+5] << 5) + (Switches[Offset+6] << 6) + (Switches[Offset+7] << 7);
Offset=8;
Bytes[1] = (Switches[Offset+0] << 0) + (Switches[Offset+1] << 1) + (Switches[Offset+2] << 2) + (Switches[Offset+3] << 3) + (Switches[Offset+4] << 4) + (Switches[Offset+5] << 5) + (Switches[Offset+6] << 6) + (Switches[Offset+7] << 7);
Offset=16;
Bytes[2] = (Switches[Offset+0] << 0) + (Switches[Offset+1] << 1) + (Switches[Offset+2] << 2) + (Switches[Offset+3] << 3) + (Switches[Offset+4] << 4) + (Switches[Offset+5] << 5) + (Switches[Offset+6] << 6) + (Switches[Offset+7] << 7);
Offset=24;
Bytes[3] = (Switches[Offset+0] << 0) + (Switches[Offset+1] << 1) + (Switches[Offset+2] << 2) + (Switches[Offset+3] << 3) + (Switches[Offset+4] << 4) + (Switches[Offset+5] << 5) + (Switches[Offset+6] << 6) + (Switches[Offset+7] << 7);
Offset=32;
Bytes[4] = (Switches[Offset+0] << 0) + (Switches[Offset+1] << 1) + (Switches[Offset+2] << 2) + (Switches[Offset+3] << 3) + (Switches[Offset+4] << 4) + (Switches[Offset+5] << 5) + (Switches[Offset+6] << 6) + (Switches[Offset+7] << 7);
Offset=40;
Bytes[5] = (Switches[Offset+0] << 0) + (Switches[Offset+1] << 1) + (Switches[Offset+2] << 2) + (Switches[Offset+3] << 3) + (Switches[Offset+4] << 4) + (Switches[Offset+5] << 5) + (Switches[Offset+6] << 6) + (Switches[Offset+7] << 7);
Offset=48;
Bytes[6] = (Switches[Offset+0] << 0) + (Switches[Offset+1] << 1) + (Switches[Offset+2] << 2) + (Switches[Offset+3] << 3) + (Switches[Offset+4] << 4) + (Switches[Offset+5] << 5) + (Switches[Offset+6] << 6) + (Switches[Offset+7] << 7);
Offset=56;
Bytes[7] = (Switches[Offset+0] << 0) + (Switches[Offset+1] << 1) + (Switches[Offset+2] << 2) + (Switches[Offset+3] << 3) + (Switches[Offset+4] << 4) + (Switches[Offset+5] << 5) + (Switches[Offset+6] << 6) + (Switches[Offset+7] << 7);

2 Comments

The issue might be system specific. I did not encounter any lag when I tried to reproduce the issue with your code in R2016a
any ideas what could cause this system-specific behaviour? We see this on various systems as well.

Sign in to comment.

Answers (0)

Categories

Find more on Language Fundamentals in Help Center and File Exchange

Products

Tags

Asked:

on 11 Jan 2017

Commented:

on 16 Jan 2018

Community Treasure Hunt

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

Start Hunting!