Diplsay Stem In App Designer Matlab
Programatically Created Random Signal Generator
Sorry if this deviates significantly from what you currently have, but here is an example of a signal generator that passes the individual fields as inputs into the callback function. Also the str2double()
function was used to parse the values of the uieditfield
s.
%App figure properties% App = uifigure(); App.Name = "Random Signal Generator"; X_Position = 200; Y_Position = 220; Height = 300; Width = 650; App.Position = [X_Position Y_Position Width Height]; %Amplitude field% X_Position = 150; Y_Position = 245; Height = 30; Width = 90; AmplitudeEditField = uieditfield('Parent',App); AmplitudeEditField.Position = [X_Position Y_Position Width Height]; %Number of samples field% SamplesEditField = uieditfield('Parent',App); SamplesEditField.Position = [X_Position Y_Position-40 Width Height]; %Start range field% nRange1EditField = uieditfield('Parent',App); nRange1EditField.Position = [X_Position Y_Position-80 Width Height]; %End range field% nRange2EditField = uieditfield('Parent',App); nRange2EditField.Position = [X_Position Y_Position-120 Width Height]; Label_1 = uilabel('Parent',App); Label_1.Position = [X_Position-90 Y_Position Width Height]; Label_1.Text = "Amplitude"; Label_2 = uilabel('Parent',App); Label_2.Position = [X_Position-90 Y_Position-40 Width Height]; Label_2.Text = "Number of Samples"; Label_3 = uilabel('Parent',App); Label_3.Position = [X_Position-90 Y_Position-80 Width Height]; Label_3.Text = "Start of Range"; Label_4 = uilabel('Parent',App); Label_4.Position = [X_Position-90 Y_Position-120 Width Height]; Label_4.Text = "End of Range"; Label_Set = findall(App,'Type','uilabel'); Red = 0.2; Green = 0.2; Blue = 0.2; set(Label_Set,'BackgroundColor',[Red Green Blue]); set(Label_Set,'FontColor','white'); set(Label_Set,'FontSize',9); set(Label_Set,'HorizontalAlignment','center'); %Calculate button properties% Generate_Button = uibutton('Parent',App); X_Position = 60; Y_Position = 60; Height = 40; Width = 180; Generate_Button.Position = [X_Position Y_Position Width Height]; Generate_Button.Text = "Generate"; Red = 0.7; Green = 0.7; Blue = 0.7; Generate_Button.BackgroundColor = [Red Green Blue]; UIAxes = uiaxes(App); X_Position = 300; Y_Position = 50; Height = 220; Width = 300; UIAxes.Position = [X_Position Y_Position Width Height]; UIAxes.XLabel.String = 'Sample Index'; UIAxes.YLabel.String = 'Amplitude'; UIAxes.Title.String = 'Generated Signal'; Generate_Button.ButtonPushedFcn = @(Generate_Button,event) GenerateButtonPushed(AmplitudeEditField,SamplesEditField,nRange1EditField,nRange2EditField,UIAxes); function GenerateButtonPushed(AmplitudeEditField,SamplesEditField,nRange1EditField,nRange2EditField,UIAxes) amplitude = (AmplitudeEditField.Value); samples = (SamplesEditField.Value); n_range1 = (nRange1EditField.Value); n_range2 = (nRange2EditField.Value); if(amplitude ~= "" && samples ~= "" && n_range1 ~= "" && n_range2~= "") amplitude = str2double(amplitude); samples = str2double(samples); n_range1 = str2double(n_range1); n_range2 = str2double(n_range2); n_range = linspace(n_range1,n_range2,samples); xn = amplitude .* sin(2*pi*randn(1,samples)); stem(UIAxes,n_range,xn); end end
Diplsay Stem In App Designer Matlab
Source: https://stackoverflow.com/questions/66193617/can-i-include-a-stem-plot-in-matlab-app-designer
Posted by: lewisyiall1981.blogspot.com
0 Response to "Diplsay Stem In App Designer Matlab"
Post a Comment