How to fix array indices must be positive integers or logical values

조회 수: 1 (최근 30일)
%I'm trying to read a wav file and plot in the time domain
[y,fs] = audioread('Samuel_Pappalardo.wav')
t = linespace (0,length(y)/fs, length(y));
figure;
plot(t,y);

채택된 답변

Walter Roberson
Walter Roberson 2021년 12월 25일
편집: Walter Roberson 2021년 12월 25일
[y,fs] = audioread('Samuel_Pappalardo.wav')
t = (0:size(y,1)-1)/fs;
figure;
plot(t, y);
The above repairs a boundary condition in your time calculation.
It does not, however, repair any index problem. If you encountered an index problem it implies that you had an existing variable named plot or linspace or length

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 12월 25일

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by