Trying to plot the cosine of an angle in app designer

3 Ansichten (letzte 30 Tage)
Michael Clopton
Michael Clopton am 21 Mai 2020
Bearbeitet: Ameer Hamza am 21 Mai 2020
I'm trying to create a button that displays values in two text boxs and plots two seperate graphs in the app designer so far the code I have is below. The program doesn't react when the button is pressed.
% Button pushed function: PlotSinCosButton
function PlotSinCosButtonPushed(app, event)
degrees = app.EnterDegreesEditField.Value;
% creates the variable for degrees.
radians = degrees.*pi./180;
% Converts degrees to radians.
yc = cos(radians);
ys = sin(radians);
plot(app.UIAxes,yc);
plot(app.UIAxes_2,ys);
yc = app.CosineoftheangleEditField.Value;
ys = app.SineoftheangleEditField.Value;
end

Antworten (1)

Ameer Hamza
Ameer Hamza am 21 Mai 2020
Bearbeitet: Ameer Hamza am 21 Mai 2020
From your code, it appears that 'degrees' is a scalar
degrees = app.EnterDegreesEditField.Value;
so you are just trying to plot a single point. By default, it will not be visible on the axes. Change your lines to this
plot(app.UIAxes, yc, '+');
plot(app.UIAxes_2, ys, '+');

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by