MATLAB GUI calling external function

5 views (last 30 days)
Jason Chang
Jason Chang on 11 May 2022
Answered: Geoff Hayes on 12 May 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 Comment
Matt J
Matt J on 11 May 2022
Edited: Matt J on 11 May 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?

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 12 May 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).

Community Treasure Hunt

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

Start Hunting!