Illegal use of reserved keyword
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
akj
am 12 Apr. 2018
Kommentiert: Monojit Chatterjee
am 12 Sep. 2020
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"
0 Kommentare
Akzeptierte Antwort
Steven Lord
am 12 Apr. 2018
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.
0 Kommentare
Weitere Antworten (1)
Guillaume
am 12 Apr. 2018
Bearbeitet: Guillaume
am 12 Apr. 2018
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 Kommentar
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!