Cant show plot on a graph matlab GUI
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
the plot for the graph dont appear when i input the values
%Reading Value for selected signal Converter
selectedFunction = app.DropDown.Value;
Fs = 1000; % Sampling frequency (Hz)
T = 1/Fs; % Sampling period (seconds)
L = 1000; % Length of signal (number of samples)
t = (0:L-1)*T; % Time vector
%Reading input parameter
f1 = str2double(app.Frequency1EditField.Value);
f2 = str2double(app.Frequency2EditField.Value);
%Initialize Signal
x = [];
%Selecting function
switch selectedFunction
case "Fourier"
x = sin(2*pi*f1*t) + sin(2*pi*f2*t);
% Add noise if the checkbox is selected (i.e., checked)
if app.WhiteNoiseRemoverCheckBox.Value
x = x + 0.5 * randn(size(t)); % Add noise when checkbox is checked
end
y = fft(x);
% Compute the two-sided spectrum
P2 = abs(y/L); % Magnitude of the FFT divided by the length
P1 = P2(1:L/2+1); % Single-sided spectrum (positive frequencies)
P1(2:end-1) = 2*P1(2:end-1); % Adjust for the single-sided spectrum
% Define the frequency axis
f = Fs*(0:(L/2))/L;
plot(app.UIAxes, t, x);
plot(app.UIAxes_2, f, P1);
0 comentarios
Respuestas (1)
Walter Roberson
el 18 de Nov. de 2024
selectedFunction = app.DropDown.Value;
That is going to reply with a character vector even if the Items was initialized with a string array. uidropdown() converts string arrays into cell array of character vectors.
0 comentarios
Ver también
Categorías
Más información sobre Graph and Network Algorithms en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!