Error "Subscript indices must either be real positive integers or logicals" in matlab

Status
Not open for further replies.

Chinmaye

Full Member level 3
Joined
Jan 18, 2016
Messages
164
Helped
0
Reputation
0
Reaction score
1
Trophy points
1,298
Activity points
3,145
Error "Subscript indices must either be real positive integers or logicals" in matlab

Hello all,
I am trying to run this simple program to calculate SNR. This is provided in the matlab documentation itself. But I get this error "Subscript indices must either be real positive integers or logicals."
Code:
rng default
Tpulse = 20e-3;
Fs = 10e3;
t = -1:1/Fs:1;
x = rectpuls(t,Tpulse);
y = 0.00001*randn(size(x));
s = x + y;
pulseSNR = snr(x,s-x)

Please help
 

Re: Error "Subscript indices must either be real positive integers or logicals" in ma

Only positive numbers can be used to index a vector.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…