Attempted to access f(97); index out of bounds because numel(f)=96.
Show older comments
I have this equation to solve the P(f). But the problem is that f is a matrix of 1x96 the zred and d18ored are both matrix 82x1. and i need to create a matrix with the dimension 82x96. with the equation p(f). i tried with the "." and without it and the error is the same
f=1:0.2:20;
for i=length(f);
ti=zred';
yi=d18ored;
T=(1/(4*pi*f(i)))*(atan(sum(sin(4*pi*f(i)*ti)))/(sum(cos(4*pi*f(i)*ti))));
P(i+1)=((sum(yi*sin(2*pi*f(i+1).*(ti-T)))).^2)/sum(sin(2*pi*f(i+1).*(ti-T)).^2))+...
((sum(yi*cos(2*pi*f(i+1).*(ti-T)))).^2)/sum(cos(2*pi*f(i+1).*(ti-T)).^2));
end
Accepted Answer
More Answers (1)
dpb
on 7 Nov 2015
for i=length(f)
The above is simply
i=length(f);
there will be only one iteration performed. Since i==length(f), clearly in
P(i+1)=((sum(yi*sin(2*pi*f(i+1) ...
the expression f(i+1) will be an out of bounds reference to f(length(f)+1). Set the upper limit to length(f)-1 to refer only to inbounds locations.
Categories
Find more on Matrix Indexing 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!