I need help, i keep getting index exceeds matrix dimensions error
Show older comments
function [] =FFAplot(a,b,k)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
A=size(a);
B=size(b);
K=size(k);
p=(1/100);
T=100;
if A(1,1)==B(1,1)
if A(1,2)==B(1,2)
if (B(1,1)==K(1,1))||(B(1,2)==K(1,2))
j=0;
i=1:K(1,2);
Qi=zeros((A(1,1)),(A(1,2)));
while j==0
%loglog((10),(10^5))
Q=((b(i,i))+(((a(i,i))/(k(i,i)))*(1-((-log(1-p))^(k(i,i))))))
%loglog(((b(i,i))+(((a(i,i))/(k(i,i)))*(1-((-log(1-p))^(k(i,i)))))),T)
end
end
end
end
end
This is my code but it keeps giving me this error
"Index exceeds matrix dimensions.
Error in FFAplot (line 17)
Qi=((b(i,i))+(((a(i,i))/(k(i,i)))*(1-((-log(1-p))^(k(i,i))))))"
Q is supposed to just return a number
Answers (1)
Jan
on 31 Jan 2018
The code cannot run for several reasons. A simplified version of the loop (avoid overdoing it with parenthesis):
j = 0;
i = 1:K(1,2);
while j==0
Q = b(i,i) + a(i,i) / k(i,i) * (1-(-log(1-p)) ^ k(i,i));
end
This will be an infinite loop, because j is not changed inside the loop.
The line from the error message "Qi=((b..." does not exist in your code. Please post the real code and the real message.
The error message means, that either a or k does not have the requested size. So check the value of i using the debugger.
Categories
Find more on MATLAB 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!