I am trying to model a dynamic system's response against a generated signal.
i modeled the system properly on simulink and it worked fine, but for the purpose of my work i needed to replicate the same simulation in a less abstract manner because i need to control the parameters of the simulation and solution a bit further.
I've managed to do so on matlab but i am facing a problem caused by sampling time scaling.
I know and understand that sampling time affects the accuracy of the simulation but at a certain threshold sampling time should be small enough that it doesn't affect the results any more.
the problem i am facing is that changing sampling time causes direct scaling of the end results of the simulation.
a sample time of .001 gives the same result as a sample time of .01 only it is multiplied by 10^-1.
My question is
- is their a way to eliminate the scaling relation between sampling time and results ?
- if i am trying to manually do the math for the simulation (which i am trying to do) is their a way to manually do variable time sampling ?
- if the scaling effect is a fact i have to accept, how to choose the best possible sample time.
thanks in advance and sorry for the long question
t = 0:0.025:15;
for i = 1:length(t)
if t(i) >= 1
wf(1,i) = 0.1;
if t(i) >= 5
wf (2,i) = 0.1;
wf1 = wf (1,:); wf2 = wf (2,:);
w = [diff(wf1) , 0 ; diff(wf2) , 0];
Susp_sys = ss((A-B*K),G,C,D);
[Y,T,x] = lsim (Susp_sys,w,t);