Why am I getting "Array indices must be positive integers or logical values"?
1 回表示 (過去 30 日間)
古いコメントを表示
I'm currently trying to plot a function from x=0 to 1 and the function "var" keeps coming up with the error code "Array indices must be positive integers or logical values". Any suggestions? Thank you
a=1;
n=1;
x=0:0.01:1;
psi=(2/a).^0.5.*sin((n*pi*x)/a);
N=(10.816).^0.5;
var=N(x.^(0.862)-x.^(2.862));
0 件のコメント
回答 (1 件)
Adam Danz
2019 年 12 月 9 日
編集済み: Adam Danz
2019 年 12 月 10 日
This line below implies that you're trying to index values from an array N where the index values must be positive integers or logicals.
N(x.^(0.862)-x.^(2.862))
Clearly the "indices" do not meet those requirements.
My guess is that the intention is to multiply N by those values.
var = N .* (x.^(0.862)-x.^(2.862));
% ^^
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Operators and Elementary Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!