how to add sinusoids in app designer in matlab

main.m
function addSinusoids(app)
    % Define parameters for the first sinusoid
    frequency1 = app.FrequencyEditField1.Value;
    amplitude1 = app.AmplitudeEditField1.Value;
    phase1 = app.PhaseEditField1.Value;
    
    % Define parameters for the second sinusoid
    frequency2 = app.FrequencyEditField2.Value;
    amplitude2 = app.AmplitudeEditField2.Value;
    phase2 = app.PhaseEditField2.Value;
    
    % Time vector
    t = 0:0.01:2*pi;
    
    % Generate the two sinusoids
    y1 = amplitude1 * sin(2*pi*frequency1*t + phase1);
    y2 = amplitude2 * sin(2*pi*frequency2*t + phase2);
    
    % Add the two sinusoids
    y = y1 + y2;
    
    % Plot the combined sinusoids
    plot(app.UIAxes, t, y);
end
712 chars
25 lines

gistlibby LogSnag