How do i correct this mistake in my matlab program? Please help.

ex(1)=lx/J %%first i term in ex matrix
ex(2)=mx/J %%second j term in ex matrix
ex(3)=nx/J %%third k term in ex matrix
for i=1:9
N_matrix(1,i)=N(rem(i,3))*ex(i / 3);(ERROR HERE)
end
Attempted to access ex(0.333333); index must be a positive integer or logical.
Error in practisee2 (line 225)
N_matrix(1,i)=N(rem(i,3))*ex(i / 3);

5 件のコメント

Walter Roberson
Walter Roberson 2018 年 10 月 16 日
Attempted to access ex(0.333333); index must be a positive integer or logical.
That is not a MATLAB error message. It might be an Octave error message. MATLAB error messages do not mention the value of the invalid subscript.
Virajan Verma
Virajan Verma 2018 年 10 月 16 日
@Walter This is a Matlab error message. I am currently using it.
Walter Roberson
Walter Roberson 2018 年 10 月 16 日
Ah, a very old MATLAB.
Virajan Verma
Virajan Verma 2018 年 10 月 16 日
Yes. It is 2015 version. How do i eliminate the error??
Walter Roberson
Walter Roberson 2018 年 10 月 16 日
First you explain what you intend it to mean. In one of your related posts you said that ex is a function, but it was clear that you had initialized ex as a variable.

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

回答 (1 件)

madhan ravi
madhan ravi 2018 年 10 月 16 日
編集済み: madhan ravi 2018 年 10 月 16 日

0 投票

ex(i / 3); Should be an integer value not a float
So try ex(i)/3

3 件のコメント

Virajan Verma
Virajan Verma 2018 年 10 月 16 日
This changes the meaning of the expression, although the error is removed.
madhan ravi
madhan ravi 2018 年 10 月 16 日
you have to explain what you want to do learn about indexing first
Walter Roberson
Walter Roberson 2018 年 10 月 16 日
What is the intended meaning of ex(i/3) when i is 1 ?

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

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

タグ

質問済み:

2018 年 10 月 16 日

コメント済み:

2018 年 10 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by