Writing equation in Simscape
Mostra commenti meno recenti
Hello All,
I got got while implementing a piece of code in Simscape. Any help would be highly appreciated.
I need to solve following equations: q(phi) = k2*phi - 0.5*(k1 - k2)(phi - delta - phi - delta) W(phi) = dq/d(phi) = k1 if phi < delta k2 if phi > delta
I have tried writing the following piece of code. It builds but when compiling from the Simulink it says the number of differential equation more than the number of variables.
component memristorLC < foundation.electrical.branch
parameters
k1 = {-3e4, 'Ohm^-1'};
k2 = {9e4, 'Ohm^-1'};
phi_0 = {0, 'V*s'};
delta = {1e-12, 'V*s'};
phi = {1e-14, 'V*s'};
end
variables
q = {3, 'A*s'};
w = {0.4, 'Ohm^-1'};
end
function setup
phi = phi_0;
if (phi_0 > delta || phi_0 < -delta)
error('Initial value of phi must be within the range of [-delta, delta]');
end
end
equations
q == k2*phi + 0.5*(k1 - k2) * (abs(phi + delta) - abs(phi - delta));
%
% if (abs(phi) < delta)
% q.der == k1*{1, 'V'};
% else
% q.der == k2*{1, 'V'};
% end
if (abs(phi) < delta)
w == k1;
else
w == k2;
end
w == q.der/{1,'V'};
i == w*v;
end
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Simulation Setup in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!