Cannot plot audio waves in specific axes??

조회 수: 3 (최근 30일)
Nirajan Shrestha
Nirajan Shrestha 2017년 12월 26일
답변: Walter Roberson 2017년 12월 26일
Hello, I am trying to plot audio waves in my axes(audioplot) which triggers after a push button - which also plays the audio. However, function that plays the audio lies in a different file from the main file.
----------------------------------------------------------------
function playbutton_ClickedCallback(hObject, eventdata, handles)
global audio_value;
playsounds(audio_value);
----------------------------------------------------------------
This function triggers playsounds.m which has this function. The argument passed is the file path that needs to read.
-------------------------
function playsounds(a)
[y, fs]=audioread(a);
sound(y, fs);
axes(handles.audioplot);
plot(y);
end
-----------------------
Now, I can play the audio file but it does not plot the waves. This is the error that is shown..
Undefined variable "handles" or class "handles.audioplot".
Error in playsounds (line 7) axes(handles.audioplot);
I have googled around and known that the handle is out of scope but I can't really find out what is happening here as the function is being called from the mainfile. It would be a great help if anyone can explain me this. Thanks in advance.

채택된 답변

Walter Roberson
Walter Roberson 2017년 12월 26일
In the place you call playsounds add handles as a second argument. In the place you define playsounds add handles as the second argument

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by