MATLAB GUI calling external function

14 Ansichten (letzte 30 Tage)
Jason Chang
Jason Chang am 11 Mai 2022
Beantwortet: Geoff Hayes am 12 Mai 2022
Hey,
For my senior project my task was to create a program that takes in user voice, and recognizes the frequency and returns the fundemental frequency of the voice. I have that task completed, but I wanted to implement that into a matlab GUI. I'm having trouble getting the GUI to read the external function. The external function that does the analysis originally took in user input to specify things such as recording length, and whether to return the exact pitch or the closest musical note ("corrected"). thanks for your help!
  1 Kommentar
Matt J
Matt J am 11 Mai 2022
Bearbeitet: Matt J am 11 Mai 2022
What is the "external function" in this case? Is it appsynthesizertestcode.m ?
How should your app be used so as to witness the problem you mention?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Geoff Hayes
Geoff Hayes am 12 Mai 2022
@Jason Chang - you will need to change the signature for your appsynthesizertestcode function so that you can pass in the parameters that you had been requesting before (via @doc:input). So perhaps something like
function appsynthesizertestcode(mode, recording_type, rec_length)
And you would call this function from your app as
% Value changed function: StartButton
function StartButtonValueChanged(app, event)
appsynthesizertestcode(app.ModeDropDown.Value, app.TypeDropDown.Value, app.recordlength.Value);
end
Note that the above will pass in strings for the mode and recording_type. Your appsynthesizertestcode function expects these to be integers so you will need to convert them from the string to the integer either before you pass them to the function or from within the function itself.
Also, you can remove calls to the app from within your function since it won't know about the app (unless you pass it in as a parameter).

Kategorien

Mehr zu Variables finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by