How to plot according to DropDown menu value?

12 ビュー (過去 30 日間)
Angel Hiram Torres Mota
Angel Hiram Torres Mota 2019 年 6 月 30 日
編集済み: Guillaume 2019 年 6 月 30 日
I want to plot in a UIAxes the selected option in the dropdown menu. Please help!
%There are 2 options in the DropDown menu (Square and Cube)
%This is what I've got so far..
function DropDownValueChanged(app, event)
value = app.DropDown.Value;
if value == Square
x = 1:5
y = (x.^2)
plot(app.UIAxes5, x,y)
end
if value == Cube
x = 1:5
y = (x.^3)
plot(app.UIAxes5, x,y)
end
end

回答 (1 件)

Guillaume
Guillaume 2019 年 6 月 30 日
編集済み: Guillaume 2019 年 6 月 30 日
if value == Square
Well, this is certainly not going to work (unless you've created a Square variable)
I suspect that
if value == "Square"
may work better, but that really depends on what you've put in the Items and ItemsData property of your dropdown (which you haven't told us).

カテゴリ

Help Center および File ExchangeSoftware Development Tools についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by