Illegal use of reserved keyword

조회 수: 8 (최근 30일)
akj
akj 2018년 4월 12일
댓글: Monojit Chatterjee 2020년 9월 12일
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"

채택된 답변

Steven Lord
Steven Lord 2018년 4월 12일
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.

추가 답변 (1개)

Guillaume
Guillaume 2018년 4월 12일
편집: Guillaume 2018년 4월 12일
Unless that function is in a larger file which is a class definition (i.e. the very first line of the file except for comments is classdef something, then yes that methods ... line is illegal.
Since it doesn't sound that your file is a class definition (otherwise you'd have said, I hope), what exactly were you hoping to achieve with that method line?
  댓글 수: 1
Monojit Chatterjee
Monojit Chatterjee 2020년 9월 12일
I dont understand what you said.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by