Answer to Question #42133 in MatLAB | Mathematica | MathCAD | Maple for Roshanak
i plot my diagram (ECG ) that i get info from database in this site:http://www.physionet.org/ with
now i have ECG diagram in matlab but i want to find value and position of max and min OF ALL OF WAVE ....but with this code i found just one min and one max and i dont know how i can write a loop or for to search and find whole Min and Max of wave with their values in axes y ... in medical field i mean find R-peaks in EKG
thanks alot and my code
x = load ('C:\ekg\example_ecg.txt');
y = x ( : , 2);
h = plot (y );
x = get(h,'XData'); % Get the plotted data
y = get(h,'YData');
imin = find(min(y) == y);% Find the index of the min and max
imax = find(max(y) == y);
text(x(imin),y(imin),[' Min ',num2str(y(imin))],...
deriv = diff(y)./x(1:end-1) % numerical derivation, function diff generates array which is one element shorter than initial one.
for i = 2:length(deriv)
if deriv(i-1)*deriv(i) < 0 % i.e. signs are different,
fprintf(1, 'Extremum in point (%f, %f)\n', x(i), y(i))
Need a fast expert's response?Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
General way is the following: one can use fft to obtain Fourier spectrum of the signal or wavedec to obtain the wavelet harmonics. If you know what noise should be filtered, you remove corresponding harmonics. For example, if all ECG data has harmonics not larger than F0, ampltitudes of all harmonics larger than F0 should be set in 0. Then one makes inverse transform of the spectrum with dropped noise harmonics and obtain filtered signal.
how can i remove noise on my ECG diagram in matlab
with wavedec function or ?
If we understand your first question right, the following method can be helpful. For example, one has
>> a = [2.3 5.8 1.1 22.53 5.1];
and we need to find all points in the interval (5, 6). We can create the logical array
>> inds = a > 4 & a < 6
0 1 0 0 1
which contains ones on positions of the needed values. Now
If a is array of maximal values found in ECG diagram, you can sort them in the ascending order
>> b = sort(a)
1.1000 2.3000 5.1000 5.8000 22.530
and take corresponding values:
>> b(1) % minimal value
>> b(end) % maximal value
>> b(end - 1) % second maximal value
Respectfully i have another question which is related to Previous Que...
now i have Coordinate of every points in my diagram ( my diagram is look like a ECG diagram)
now in your opinion with these info how can i find specific point or better than specific line in my diagram ???
if you cannt explain my problem please help me that how to find the first maximum relative after all of min absolute in matlab ....
You're welcome. We are glad to be helpful. If you really liked our service please press like-button beside answer field. Thank you!
it works.....thankssssssssssssssssss aloooooot ...... really really really thanks