Why FOR LOOP doesn't work for the descrete state space?
3 views (last 30 days)
Show older comments
Hello I want to plot the states of the system shown in the code attached. but the problem is that when I plot both descrete and continous system using ss, I get the right plotting but when i use the FOR LOOP the descrete state space doesn't seem to give the right plotting. Can anyone give an explaination for that because the FOR LOOP seems to work evectivelly with the descrete system? The following image shows both the descrete and continuous state system plotting using ss
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193291/image.jpeg)
This image shows the continuous state using FOR LOOP
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193293/image.jpeg)
but when I plot the descrete state system using the FOR LOOP I get a wrong plotting
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193294/image.jpeg)
Thanks in advance
0 Comments
Accepted Answer
Aquatris
on 7 Aug 2018
Edited: Aquatris
on 7 Aug 2018
The reason is continous time and discrete time A and B matrices are different. In the code you are not using the right A and B matrices.
You should have the following code for discrete time;
sysDes=ss(expm(A*T),inv(A)*(expm(A*T)-eye(2))*B,C,D,T);
Also in discrete time you do not use integration operation. The discrete time state space equation already includes the integration step;
x[k+1] = Ad*x[k]+Bd*u
I recommend you check out how to discretize a continuous time state space to better understand this. Wikipedia has a nice article on it. You do not simply use the same A and B matrices.
0 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!