user12881666
user12881666

Reputation:

"Warning: Simulation will start at a nonzero initial time" how could i fix this error?

This is my code my how could I avoid "Warning: Simulation will start at a nonzero initial time."?

A=[1]
B=[0.12]
C=[1]
D=[0]
u=[-0.0137 -0.012 -0.009 -0.005 -0.003 -0.003 0.001];
x0 = 0.9914;
Ts=1;
sistema=ss(A,B,C,D,Ts)
t=[2013 2014 2015 2016 2017 2018 2019];    
y=lsim(sistema,u,t,x0);
plot(t,y) 

Upvotes: 0

Views: 937

Answers (2)

user1543042
user1543042

Reputation: 3440

How @Kavka suggested is also how I would fix the warning; however, you could return that warning off using warning (https://www.mathworks.com/help/matlab/ref/warning.html#d118e1583587). Use lastwarn to get the warning

Upvotes: 0

anon
anon

Reputation:

Since you are simulating a time-invariant system, you can simply shift your time vector to start from zero when calling the lsim command. The resulting vector y will be the same in both cases, but the shifted case won't have the warning:

>> y = lsim(sistema,u,t,x0)
Warning: Simulation will start at a nonzero initial time. 
y =
  0.9914
  0.9898
  0.9883
  0.9872
  0.9866
  0.9863
  0.9859

>> y = lsim(sistema,u,t-t(1),x0)
y =
  0.9914
  0.9898
  0.9883
  0.9872
  0.9866
  0.9863
  0.9859

Upvotes: 1

Related Questions