MATLAB Answers

0

How to add constant line in appdesigner

Asked by Daniel Boateng on 24 May 2019
Latest activity Edited by Kojiro Saito on 24 May 2019
I want to add a constant line in the plot axes in appdesigner. I tried the command plot(app.UIAxes,xline(app.DCValueDropDown.Value)) where the drop down values are values from (10 to 20). But it isnt working. Any ideas please?

  0 Comments

Sign in to comment.

1 Answer

Answer by Kojiro Saito on 24 May 2019
Edited by Kojiro Saito on 24 May 2019
 Accepted Answer

Data type of dropdown.Value is a character, so you need to covert it to number.
The following will work. Please replace "plot" command depending on your data.
function startupFcn(app)
plot(app.UIAxes, 1:20, 1:20)
app.xl = xline(app.UIAxes, str2double(app.DCValueDropDown.Value));
end
function DCValueDropDownValueChanged(app, event)
value = app.DCValueDropDown.Value;
% Change xline value
app.xl.Value = str2double(value);
end
Below is a preview.

  0 Comments

Sign in to comment.