It's pretty well explained by the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_fix_the_error_.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22.3F
why this message error ?:Array indices must be positive integers or logical values
1 view (last 30 days)
Show older comments
jérôme TAÏEB
on 30 Sep 2018
Answered: Image Analyst
on 30 Sep 2018
Hi,
When i write this little script:
---------------------------------------------------------------------------------------------------------
demo matlab
t = (10:1:200)';
y = sin(2*pi*50*t)
z = y(t-10)
w = y+z
plot(t(1:50),w(1:50))
sound(w,Fs);
-------------------------------------------------------------------------------------------------------
there is a message error: message error: Array indices must be positive integers or logical values.
Howewer,when i write this:
-----------------------------------------------------------------------------------------------------
demo matlab
t = (0:0.001:100)';
y = sin(2*pi*50*t)
plot(t(1:50),y(1:50))
sound(y,Fs);
------------------------------------------------------------------------------------------------------
there is no message error.
Why?
thanks
0 Comments
Accepted Answer
More Answers (2)
jérôme TAÏEB
on 30 Sep 2018
3 Comments
Star Strider
on 30 Sep 2018
The sound is there. It is of too short a duration to notice:
signal_duration = (200-11)/44000
signal_duration =
0.00429545454545455
It only lasts for 4.3 milli-seconds!
Image Analyst
on 30 Sep 2018
See attached sound making demo. It doesn't make your sound but adapt it as needed.
0 Comments
See Also
Categories
Find more on Startup and Shutdown 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!