MATLAB GUI calling external function

7 ビュー (過去 30 日間)
Jason Chang
Jason Chang 2022 年 5 月 11 日
回答済み: Geoff Hayes 2022 年 5 月 12 日
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 件のコメント
Matt J
Matt J 2022 年 5 月 11 日
編集済み: Matt J 2022 年 5 月 11 日
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?

サインインしてコメントする。

回答 (1 件)

Geoff Hayes
Geoff Hayes 2022 年 5 月 12 日
@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).

カテゴリ

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by