Borrar filtros
Borrar filtros

How to get values from multiple plots obtained from a loop?

1 visualización (últimos 30 días)
mahrukh jamil
mahrukh jamil el 12 de Ag. de 2016
Comentada: mahrukh jamil el 1 de Sept. de 2016
hi, I have an ECG data file for recording of 6- 8 hours.I implemented a window so that i have different pieces of data and i could apply function on it. I tried to run the window in the loop. *) My question how to get values for the iterations for different functions and plots. if I add the iteration as count, I could get any function run for those iteration within the loop but this thing doesn't seems to be applicable to every function. for example when I want to get the mean for count as RMSS (count)= mean(RR_interval); it works fine. but for RR_interval(count)= diff(Locs); it doesn't
specially i want to know how can i get the values from the multiple plots that are produce from the loop. Here is my code. %%
ECG_14003= R(27,:);
N_max=length(ECG_14003);
fs = 256;
n_window=5120;
for n_start = 1:n_window:(N_max-n_window)
New_data = ECG_14003(n_start:(n_start+ n_window));
[pks, locs]=findpeaks(New_data,'MinPeakProminence',100);% peak location of ECG in the current window
RR_interval = diff(locs);%Peak interval
RR_length= length(RR_interval);
[pxx, F]=pwelch(RLocsInterval,RR_length, [],nfft,fs, 'twosided');
plot(freq, 10*log10(pxx)); hold on
xlabel('Frequency Hz')
ylabel('power spectral density')
count=count+1;
end
*) If I add hold on, would it give me the plots for each iteration? And how can i retrieve those values for F for each window/iteration
  2 comentarios
Jeevan Joishi
Jeevan Joishi el 23 de Ag. de 2016
Editada: Jeevan Joishi el 23 de Ag. de 2016
Hi Mahrukh,
I am afraid I did not fully understand what you meant by 'get the values from multiple plots'. Can you please elaborate on it.
That being said, I believe you are looking for a way to plot graphs in an iteration. Here are two possible scenarios that I can think of which might be useful to you -
1. If you plan on creating a separate figure in each iteration, you can simply add a the following statement before the call to 'plot' command.
>> figure;
This will cause each of the plots to be displayed on the separate figure.
2. Since your sample code has reference to the command 'hold on', so I have a strong feeling that you are looking to plot values from each iteration to the same graph and see sort of a trend line. You can use the function 'linkdata' that can be used to monitor changes to a variable in real time. More information about linkdata can be found at this link.
mahrukh jamil
mahrukh jamil el 1 de Sept. de 2016
Thank you for your answer. I did figure it out but your answer also gave me a new perspective.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Visual Exploration en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by