Array indices must be positive integers or logical values.
1 view (last 30 days)
Show older comments
Tove Rudöfors
on 9 Oct 2019
Commented: Tove Rudöfors
on 9 Oct 2019
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 Comments
Accepted Answer
meghannmarie
on 9 Oct 2019
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 Comments
meghannmarie
on 9 Oct 2019
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.
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!