Array indices must be positive integers or logical values.

2 ビュー (過去 30 日間)
Tove Rudöfors
Tove Rudöfors 2019 年 10 月 9 日
コメント済み: Tove Rudöfors 2019 年 10 月 9 日
E = 10;
R1 = 10e3;
R2 = 1e3;
R3 = 4.7e3;
R4 = 10e3;
R5 = 10e3;
RX = 1e3;
RY = 1e3;
J = [E/R5 ; - E/R5; 0 ];
RYs = logspace(-3, 10, 10000);
IXs = [];
for ry = RYs
G = [ -(1/R5+1/R4+1/RX) 1/R5 1/RX;
1/R5 -(1/R5+1/R2+1/ry+1/R1) 1/R1;
1/RX 1/R1 -(1/R1 + 1/R3 + 1/RX) ];
V = G\J;
IXs(end+1) = ( V(3) - V(1) ) / RX;
end;
PXs = IXs .* IXs * RX;
figure('Name','RYandIXs','NumberTitle','off'); semilogx(RYs, IXs);
figure('Name','RYandPXs','NumberTitle','off'); semilogx(RYs, PXs);
maxIXs= max(IXs),
minIXs =min(IXs),
maxPXs= max(PXs),
minPXs = min(PXs)
MaxPXsAt = RYs(find(PXs == max(PXs)))
So this is the code I have written. Everything works fine except for the two min- functions. When I run the code I get the message "Array indices must be positive integers or logical values.". I have searched the internet for answers but no solution seems to be the one for me. Anyone know what might be the problem? Thank you :)

採用された回答

meghannmarie
meghannmarie 2019 年 10 月 9 日
I ran your code and it works for me. This leads me to believe you might have a variable in your workspace named min. Try this:
which min
If that tells you min is a variable, rename that variable to something else.
  3 件のコメント
meghannmarie
meghannmarie 2019 年 10 月 9 日
I have had this happed to me numerous times by naming variables min, mean, max. So I figured thats what was happening when you posted this. Now I name my variables mn, avg, and mx.
Tove Rudöfors
Tove Rudöfors 2019 年 10 月 9 日
That's a really good tip! I will definitely be doing that too from now on. Thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by