インデックスが配列要素数(1)を超えています。

38 visualizaciones (últimos 30 días)
尾﨑 健祐
尾﨑 健祐 el 2 de Ag. de 2020
Respondida: Kojiro Saito el 3 de Ag. de 2020
>> s=tf('s')
インデックスが配列要素数(1)を超えています。
このエラーの意味がわかりません。MATLAB2020を使用しています。

Respuestas (1)

Kojiro Saito
Kojiro Saito el 3 de Ag. de 2020
おそらくtfはstruct(構造体配列)でしょうか。1行1列の構造体のようなので、tf(1)はリターンが返ってきますが、それより大きな数字を入れると要素数を超えるという上記のエラーが起きてしまいます。「's'」を入れるとdouble('s')の値115と解釈されてしまい、tfの115の要素数にアクセスしてしまうため、このようなことが起きてしまいます。
要素の値を取得するには、struct名.フィールド名か、struct名.('フィールド名')を使います。
s = tf.s;
または
s = tf.('s');

Categorías

Más información sobre 構造体 en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!