i have this in the code view for the app:
% Button pushed function: PlotButton
function PlotButtonPushed(app, event)
fnam = uigetfile ('*.dat','Escolha o ficheiro');
fid = fopen(fnam);
ecg = fscanf(fid,'%f');
fs = 200; %sampling rate
sze = length(ecg);
necg = ecg/max(ecg); % normalize the maximum value to unity
time = (1:sze)/fs;
[mins, maxs] = picos (necg);
figure;
plot(app.UIAxes, time, necg, 'b');
hold on;
plot (app.UIAxes, time(maxs), necg(maxs), 'red*');
plot (app.UIAxes, time(mins), necg(mins), 'ko'); hold off;
axis tight;
ylabel(app.UIAxes, 'ECG');
xlabel(app.UIAxes, 'Time in seconds');
But when i press run, and then the plot button, choose a file, all i get in the Axes window is the black dots that mark valleys in the signal plus, it opens a different window with a blank figure. I need to show the signal, the valleys marked with a dot and the peaks marked with a star in the app.UIAxes and i dont want to open the other window with the blank figure.
Here is the code for "picos" function:
function [mins, maxs] = picos (sinal)
mins = [];
maxs = [];
t = 1:length (sinal);
for i = 2:length(sinal)-1
if sinal(i-1) > sinal(i) && sinal(i) < sinal(i+1)
mins = [mins i]; %faz acrescentar o valor de i ao array mins
end
if sinal(i-1) < sinal(i) && sinal(i) > sinal(i+1)
maxs = [maxs i]; %faz acrescentar o valor de i ao array maxs
end
end
% plot (t, sinal, 'm-'); hold on;
% plot (t(maxs), sinal(maxs), 'b*');
% plot (t(mins), sinal(mins), 'go'); hold off;
% title ('Deteção picos'); xlabel ('Tempo (s)'); ylabel ('Sinal (t)');
end
Thank you!