Trying to plot the cosine of an angle in app designer

3 次查看(过去 30 天)
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

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-5-21
编辑:Ameer Hamza 2020-5-21
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, '+');

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by