Changes

Jump to navigation Jump to search

Ocs package

1,412 bytes added, 02:38, 22 September 2015
endfunction
</syntaxhighlight>
}}
 
 
 
As an example let's run a simulation by applying a sinusoidal signal with varying
frequency
 
{{Code| memristor model implementation|<syntaxhighlight lang="octave">
t = linspace (0, 1, 100);
y = [(sin (2 * pi * t * 1.5)), (sin (2 * pi * t * 4))(2:end)];
t = [t, (linspace (1, 2, 100))(2:end)];
pwl = [t; y](:).';
 
c1.LCR = [];
c1.totextvar = 1;
 
c1.NLC(1).("func") = "Mvoltagesources";
c1.NLC(1).("section") = "pwl";
c1.NLC(1).("nextvar") = 2;
c1.NLC(1).("npar") = 398;
c1.NLC(1).("nrows") = 1;
c1.NLC(1).("nparnames") = 0;
c1.NLC(1).("parnames") = {};
c1.NLC(1).("pvmatrix") = pwl;
c1.NLC(1).("vnmatrix") = [1 0];
c1.NLC(1).("nintvar") = 1;
c1.NLC(1).("osintvar") = 0;
 
c1.NLC(2).("func") = "Mmemristors";
c1.NLC(2).("section") = "STRUKOV";
c1.NLC(2).("nextvar") = 2;
c1.NLC(2).("npar") = 3;
 
c1.totintvar = 2;
c1.namesn = [1 2 3];
 
c1.NLC(2).("nrows") = 1;
c1.NLC(2).("nparnames") = 3;
c1.NLC(2).("parnames") = {"MU", "RH", "RL"};
c1.NLC(2).("pvmatrix") = [1.8e3 1e3 1];
c1.NLC(2).("vnmatrix") = [1 0];
 
c1.NLC(2).("nintvar") = 1;
c1.NLC(2).("osintvar") = 1;
 
c1.namess = {"voltage", "current", "x"};
start = [0 0 0.1];
 
%% c = prs_iff ("memristor_example");
out = tst_backward_euler (c1, start.', t, 1e-2, 300, {'voltage', 'current'});
 
plot (out(1, 1:100), out (2, 1:100), 'r',
out(1, 101:end), out(2, 101:end), 'k')
 
legend ("frequency 1 Hz", "frequency 4 Hz")
 
</syntaxhighlight>
}}
344

edits

Navigation menu