Plotting in Matlab appdesigner
Mostrar comentarios más antiguos
I'm trying to create a random signal generator with stem plot in Matlab App Designer, and when I click the 'Generate' Button - nothing happens. Below is the code I added in the generated code from the app designer.
methods (Access = private)
%generate button is pushed
function GenerateButtonPushed(app, event)
amplitude = app.AmplitudeEditField.Value;
samples = app.SamplesEditField.Value;
n_range1 = app.nRange1EditField.Value;
n_range2 = app.nRange2EditField.Value;
n_range = n_range1:n_range2;
xn = amplitude .* sin(2*pi*randn(1,samples));
%plot random signal
stem(n_range,xn, 'parent', app.UIAxes)
end
end
When I ran this block of code in a live script in Matlab. It worked, but the graph won't show when I run it with the GUI.


Respuesta aceptada
Más respuestas (1)
randerss simil
el 14 de Feb. de 2021
Editada: randerss simil
el 14 de Feb. de 2021
%if true
function GenerateButtonPushed(app,eventData)
It's eventdata instead of event
2 comentarios
randerss simil
el 14 de Feb. de 2021
Editada: randerss simil
el 14 de Feb. de 2021
The functuon input argument must call eventdata when the button is pushed.
Claudee Khiarra Directo
el 14 de Feb. de 2021
Categorías
Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!