Trying to plot the cosine of an angle in app designer

3 views (last 30 days)
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

Answers (1)

Ameer Hamza
Ameer Hamza on 21 May 2020
Edited: Ameer Hamza on 21 May 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, '+');

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!