Array indices must be positive integers or logical values.
1 次查看(过去 30 天)
显示 更早的评论
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 :)
0 个评论
采纳的回答
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
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!