Quick question about appDesigner - need an example

6 ビュー (過去 30 日間)
Alasdair McAndrew
Alasdair McAndrew 2016 年 10 月 27 日
編集済み: Kevin Gurney 2016 年 11 月 2 日
I've been using Matlab for a very long time, but I've never bothered with building any GUIs with it. So now I'm just dipping my toes into appDesigner. And as a trial, I thought I'd make a simple app with two sliders (for x and y coordinates) and some axes, on which would be drawn a circle with radius 1 and center given by the sliders. I think I've got all the bits, but they aren't talking to each other: I don't know that my circle plotting function is picking up the values from the sliders, or that the plot is being sent to the axes. At any rate, nothing is being drawn.
What I want is some more examples than the ones provided: in particular an example of an app, built with appDesigner, in which a plot changes in response to a slider.
Can anybody point me in the direction of one such?
Thanks!

回答 (1 件)

Kevin Gurney
Kevin Gurney 2016 年 11 月 2 日
編集済み: Kevin Gurney 2016 年 11 月 2 日
My understanding is that you would like a simple example of an App Designer application that contains a plot which responds to changes in a slider.
This functionality can be achieved using the basic workflow outlined below:
  1. Select the slider within the App Designer Design View.
  2. Navigate to the "Slider & Label Properties" menu on the right side of the App Designer.
  3. Click the "Callbacks" tab of the "Slider & Label Properties" menu.
  4. Enter a callback function name for the "ValueChanging" event (let's assume you call the function "updatePlot").
  5. Implement the callback function ("updatePlot") for the slider's "ValueChanging" event within the App Designer Code View.
The implementation of the callback function ("updatePlot") for the "ValueChanging" event could be something as simple as:
function updatePlot(app, event)
plot(app.UIAxes, event.Value, event.Value, 'bo');
end
The code above will set the x and y coordinates of a blue circle on a plot to the value of the slider as it is changed by the user.

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by