I think I've figured this out for my own problem. I'll post what I think is the answer in case it's helpful to someone.
What is still "wrong", is that the initial DCOP found by simscape isn't what I expect. There could be something wrong with this model or maybe I don't know how to use the solver.
component myComponent
% Non-working attempt at creating a Custom Simscape component
% from a state space system
nodes
p=foundation.electrical.electrical; % 1:left
n=foundation.electrical.electrical; % 2:left
end
variables
i1 = { 0, 'A'}; % current into port 1
i2 = { 0, 'V'}; % current into port 2
x = {zeros(30,1), 'V'} % internal state variable
end
branches
i1 : p.i -> n.i
i2 : n.i -> p.i
end
parameters
E = {0, 's'} % units to avoid complaints
A = {0, '1'}
B = {0, '1'}
C = {0, '1/Ohm'}
end
function setup
E = {"some 30x30 matrix", 's'}
A = {"some 30x30 matrix", '1'}
B = {"some 30x2 matrix", '1'}
C = {"some 2x30 matrix", '1/ohm'}
end
equations
E*x.der == A*x + B*[p.v; n.v];
[i1; i2] == C*x;
end
end