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

1 回表示 (過去 30 日間)
mahrukh jamil
mahrukh jamil 2016 年 8 月 12 日
コメント済み: mahrukh jamil 2016 年 9 月 1 日
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 件のコメント
Jeevan Joishi
Jeevan Joishi 2016 年 8 月 23 日
編集済み: Jeevan Joishi 2016 年 8 月 23 日
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 2016 年 9 月 1 日
Thank you for your answer. I did figure it out but your answer also gave me a new perspective.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by