MATLAB: Left hand side of the equation is not equal to the right hand side

model errorsimulink

Error compiling Simscape network for model untitled1.
Caused by:
['untitled1/Op-Amp']: Type mismatch for equation. The left hand side of the equation is {[1x1 double], 'V'} and the right hand side of the equation is 1.
v1 = {[1x1 double], 'V'}
In foundation.electrical.elements.op_amp (line 33)
Component:Simulink | Category:Model error
And the code is as below,
component op_amp
% Op-Amp
% Models an ideal Operational Amplifier (Op-Amp). If the voltage at the
% positive pin is denoted by Vp, and the voltage at the negative pin by Vm,
% then an ideal op-amp behavior is defined by Vp = Vm. In other words, the
% op-amp gain is assumed to be infinite. By implication, the current from
% the Vp to the Vm terminal is zero
% Copyright 2005-2013 The MathWorks, Inc.
nodes
p = foundation.electrical.electrical; % +:left
n = foundation.electrical.electrical; % -:left
out = foundation.electrical.electrical; % :right
end
variables(Access=private)
i1 = { 0, 'A' }; % Input current
v1 = { 0, 'V' }; % Input voltage
end
variables
outI = { 0, 'A' }; % Current into output node
end
branches
i1 : p.i -> n.i;
outI : out.i -> *;
end
equations
v1 == p.v - n.v;
v1 == 1;
i1 == 0;
end
end

Best Answer

v1 == 1;
would have to be
v1 == {1, 'V'};
You made v1 be a number of volts, but the right hand side, the == 1, is a pure number, not a voltage.
Related Question