Unknown exception 0x80000026 Error/Crash with Simulink

8 views (last 30 days)
Hello, I have created a system object inside a simulink model. Right now it does something like this (nothing so far:P, because I'm stuck on technicalities):
function setupImpl(obj,u)
% Implement tasks that need to be performed only once,
% such as pre-computed constants.
obj.memory = -ones(11, 11);
end
function [Out] = stepImpl(obj,message)
% Implement algorithm. Calculate y as a function of
% input u and discrete states.
i = find(obj.memory(:,1) == message(1));
if(all(i ~= 0)) %find id already in memory
Out = i(1);
else
Out = i(1);
end
end
When it executes it crashes with this error message: Unknown exception 0x80000026 I realized that I have to use the scalar value of i, but when I call it i(1) it won't work. Also i is always supposed to either be empty or return 1 index (there cannot be more than 1 occurrence).
Any ideas?
  1 Comment
highWaters
highWaters on 28 Jan 2016
Edited: Walter Roberson on 28 Jan 2016
I made this modification:
function [Out] = stepImpl(obj,message)
i = find(obj.memory(:,1) == message(1),1);
if(isempty(i) ~= 0)
Out = i(1);
else
Out = i(1);
end
end
But still when I try to access i(1) the crash persists.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 28 Jan 2016
if isempty(i)
Out = [];
else
Out = i(1);
end

More Answers (0)

Categories

Find more on Configure and View Diagnostics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!