MATLAB: Illegal use of reserved keyword

app designermatlab gui

function PLAYNOTE(app,frequency)
FreqString=num2str(frequency);
app.Label.Text=FreqString;
%https://www.mathworks.com/help/signal/ug/edit-time-information-in-the-signal-analyzer-app.html
%below details can be obtained from the above mentioned websites./
SampleRate = app.samplerate;
TimeValue = app.timevalue;
TimeSamples = 0:SampleRate:TimeValue;
FORSINE=app.SINE.Value;
FORSQUARE=app.SQUARE.Value;
FORSAWTOOTH=app.SAWTOOTH.Value;
if FORSINE == 1
soundVector = sin(2*pi*frequency*TimeSamples);
elseif FORSQUARE == 1
soundVector = square(2*pi*frequency*TimeSamples);
elseif FORSAWTOOTH == 1
soundVector = sawtooth(2*pi*frequency*TimeSamples);
end
sound(soundVector, 1/SampleRate)
CheckRecord=app.RECORD.Value;
if CheckRecord == 1
SOUNDCOMPOSE=app.Soundvector;
if SOUNDCOMPOSE == 0
SOUNDCOMPOSE=soundVector;
else
SOUNDCOMPOSE=cat(2,SOUNDCOMPOSE,soundVector);
end
app.Soundvector=SOUNDCOMPOSE;
end
end
methods (Access = private)%showing error at this line....Illegal use of reserved keyword"methods"

Best Answer

This looks like a portion of an App Designer app, and if it is that is indeed a classdef file. Looking at the end keywords, the last one before the methods line ends the function. There is no end ending the previous methods block. You can't start a methods block inside another methods block.
end the methods block that contains PLAYNOTE before starting another one for your private methods.