Need help plotting multiple graphs in one UIAxes
5 views (last 30 days)
Show older comments
I need help because I can't seem to plot multiple graphs in one UIAxes. Basically there are multiple checkboxes like sine,cosine, and tangent and when multiple boxes are checked they need to be on the UIAxes but I can't figure out a way to do that even when I use hold on function they still only graph one of them. Here's what I've got working
% Button pushed function: Graphb
function GraphbButtonPushed(app, event)
x = str2num(app.Valuesx.Value);
cla(app.UIAxes);
if (app.Plotb.Value == true)
if (app.sinBox.Value == 1)
plot(x,sin(x),'Parent',app.UIAxes)
hold(app.UIAxes,'on')
elseif (app.cosBox.Value == 1)
plot(x,cos(x),'Parent',app.UIAxes)
hold(app.UIAxes,'on')
elseif (app.tanBox.Value == 1)
plot(x,cos(x),'Parent',app.UIAxes)
hold(app.UIAxes,'on')
end
end
end
end
0 Comments
Accepted Answer
G A
on 26 Apr 2019
Your if-statement is returning only one option. Try the following way:
function GraphbButtonPushed(app, event)
x = str2num(app.Valuesx.Value);
cla(app.UIAxes);
hold(app.UIAxes,'on')
if (app.Plotb.Value == true)
if (app.sinBox.Value == 1)
plot(x,sin(x),'Parent',app.UIAxes)
end
if (app.cosBox.Value == 1)
plot(x,cos(x),'Parent',app.UIAxes)
end
if (app.tanBox.Value == 1)
plot(x,cos(x),'Parent',app.UIAxes)
end
end
end
end
0 Comments
More Answers (0)
See Also
Categories
Find more on Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!