フィルターのクリア

Index in position 2 exceeds array bounds (must not exceed 1).

1 回表示 (過去 30 日間)
Jamie Jenkinson
Jamie Jenkinson 2021 年 4 月 17 日
コメント済み: Jamie Jenkinson 2021 年 4 月 17 日
clc
A= [ -0.0240 -9.5113 0 -0.2973
0.0010 -1.1746 0 1.1758
0 2.3532 -0.9461 -2.3532
0 0 1.0000 0];
B = [0.8 0; 0 0; 0 -2.39; 0 0];
C = [1 0 0 0];
D = [0 0];
sys_1=ss(A,B,C,D);
[n1,d1]=ss2tf(A,B,C,D,2);
time = 0:0.005:10;
figure(1);
y_v=step(sys_1,time);
V_Plot=plot(time,y_v(:,2,1),'LineWidth',2);
ylabel('(m/s)');
xlabel('(s)');
title('V');
grid on;
Index in position 2 exceeds array bounds (must not exceed 1).
Error in SS2TF (line 14)
V_Plot=plot(time,y_v(:,2,1),'LineWidth',2);
Im trying to run this code. Im looking to extract data from the four columns of matrix A, and the 2 columns of matrix B. I thought this was done using the (:,:,:) after the step of the plot but I keep getting an error saying ive exceeded array bounds. I thought there was a way I can get the (muse not exceed) to 4, and 2 if that makes sense. However it wont let me exceed 1 for both. Any help is appreciated
  1 件のコメント
Clayton Gotberg
Clayton Gotberg 2021 年 4 月 17 日
What size is y_v? MATLAB's step command should only return one state at a time with the inputs you've supplied here.
If you want multple states, change the output matrix C from [1 0 0 0] (outputting only the first state) to something like [1 0 0 0; 0 1 0 0] (outputting the first and second states).

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

採用された回答

David Fletcher
David Fletcher 2021 年 4 月 17 日
編集済み: David Fletcher 2021 年 4 月 17 日
y_v is 2001x1x2 - you are trying to index the second column which does not exist. Do you mean this?
clc
A= [ -0.0240 -9.5113 0 -0.2973
0.0010 -1.1746 0 1.1758
0 2.3532 -0.9461 -2.3532
0 0 1.0000 0];
B = [0.8 0; 0 0; 0 -2.39; 0 0];
C = [1 0 0 0];
D = [0 0];
sys_1=ss(A,B,C,D);
[n1,d1]=ss2tf(A,B,C,D,2);
time = 0:0.005:10;
figure(1);
y_v=step(sys_1,time);
V_Plot=plot(time,y_v(:,1,2),'LineWidth',2);
ylabel('(m/s)');
xlabel('(s)');
title('V');
grid on;
this gives
  1 件のコメント
Jamie Jenkinson
Jamie Jenkinson 2021 年 4 月 17 日
Yes this is perfect thank you. I somehow managaed to make y_v 2001x4x2 and hence was allowed to use the second array of 4.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by