Need help with using stairs function

Hello, Can someone help me using staris function. When I use the following code, it doesn't show any error but there's only empty figure.
A = [0 0 -2;1 0 -5;0 1 -4];
b = [1;0;0];
c = [8 -26 66];
d = [];
ts = 0.1;
%[ad,bd,cd,dd] = discretise(A,b,c,d,ts);
u = 1;
I = eye(3);
G = expm(A*ts);
H = inv(A)*(G-I)*b;
x{1} = zeros(3);
%figure
for k=1:1:100
kT{k}=[0;0;0]+k-1;
x{k+1}=G*x{k}+H;
y{k}=c*x{k};
end
for i=1:10:100
hold on
stairs(kT{i},y{i});
%stem(kT{i},y{i});
end

 採用された回答

Star Strider
Star Strider 2020 年 5 月 9 日

1 投票

Try this:
kTm = cell2mat(kT);
ym = cell2mat(y.').';
figure
stairs(kTm(1,:), ym(1,:).')
grid
The cell arrays appear to have triplicate rows or columns, so convert them to matrices, transpose ‘y’, and choose one row of each to plot.

2 件のコメント

Nimms16
Nimms16 2020 年 5 月 9 日
編集済み: Stephen23 2020 年 5 月 9 日
It works perfectly. Thank you.
Star Strider
Star Strider 2020 年 5 月 9 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

質問済み:

2020 年 5 月 9 日

編集済み:

2020 年 5 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by