for f=1:0.2:20;
ti=length(f);
T=(1/4*pi*f)*atan(sum(sin(4*pi*f*ti))/sum(cos(4*pi*f*ti)));
P(f)=(sum(d18ored*sin(2*pi*f.*(ti-T)).^2))/(sum(sin(2*pi*f.*(ti-T).^2)))...
+(sum(d18ored*cos(2*pi*f.*(ti-T)))).^2/(sum(cos(2*pi*f.*(ti-T)).^2));
plot(P(f),f)
end
d18ored is a matrix 82x1 it is suppose to give me a 82x96 and gives me a error.
"Subscript indices must either be real positive integers or logicals."

1 Kommentar

In an assignment A(I) = B, the number of elements in B and I must be the same. now i got this error

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Thorsten
Thorsten am 5 Nov. 2015

0 Stimmen

f takes values 1, 1.2, 1.4, ... 20, and you try to use f as subscript
P(f)
which is not allowed.
You can use
fvec = 1:0.2:20;
for i = 1:numel(fvec)
f = fvec(i);
T = ...
P(i) = ...
end

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics and Optimization finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by