How can I code pseudo random binary sequence input current signal made by idinput?

15 visualizzazioni (ultimi 30 giorni)
I tried to define a prbs current signal input as function of time, something like:
u=idinput(100,'prbs',[0 1],[1 3]);
u=iddata([],u,1);
I(t)=u;
so when I give t get I(t) at that time to use in my ode equation:
function rate=rate_equ(t,y)
global q Vg Nsd Ssd Beta Gamma A0 N0 Epsil Tp Tc Vact Alpha
%---- Computing the Rate Equations ------------------------------
rate = zeros(2,1);
rate(1) = (Gamma*A0*Vg*((y(2)-N0)/(1+Epsil*y(1)))-1/Tp)*y(1)+Beta*Gamma*y(2)/Tc + ...
randn*sqrt(2*Beta*Vact*Nsd*(Vact*Ssd+1)^3/Tc) ;
rate(2) = I(t)/(q*Vact)-y(2)/Tc-Vg*A0*y(1)*(y(2)-N0)/(1+Epsil*y(1)) + ...
randn*sqrt(2*Vact*Nsd/Tc*(Beta*Vact*Ssd+1)) ;
end

Risposta accettata

Walter Roberson
Walter Roberson il 16 Gen 2021
When your functions use random numbers, such as your call to randn(), then they are never ODE (Ordinary Differential Equations).
The tools for Stocastic Differential Equations are in the Finance toolbox; https://www.mathworks.com/help/finance/sde-objects.html
If you were to remove the randn() then you would still have problems. The ode*() routines are only valid when the functions you provide are twice differentiable, which is never the case when you move abruptly between two states as in your PRBS data.
The ode*() routines are not fixed step-size routines: they are variable step size. So the function will not just be executed with respect to time 0, dt, 2*dt, 3*dt, and so on. You therefore need some way of mapping from the input time (first value passed to the ode function) and the sample number, such as by using interp1(). But! Interp1() use 'linear' by default, and the values produced by 'linear' or 'previous' or 'next' interpolation methods are not twice differentiable. And if you use interp1() with spline, then that is twice differentiable, but it will also have intermediate values between 1 and 3 (your signal bounds), which is incompatible with the idea of using a pseudo random binary signal.
  10 Commenti
l l
l l il 20 Gen 2021
My thanks and appreciation for your guidance.It works well for me.
Another question that I have is that I actually want to use this procedure in dde23 function
but I don't know how to set 'Jumps' to avoid wrong answer of discontinuous.
Walter Roberson
Walter Roberson il 20 Gen 2021
You are using random numbers. The system is discontinuous. If you are fortunate, you would get explicit error messages telling you that your functions are not suitable for the ode functions that you are using.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Data Type Identification in Help Center e File Exchange

Prodotti


Release

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by