Finding x value at 10% of max y value, after the max
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to find the x value at 90% of my max y value, after the peak. Below is something I have tried using other MATLAB Answers and recieved an error message for (probably because I am not modifying them correctly). I am also attaching a figure of my curves. In my code I am only looking at the first blue curve. It looks like I should get a value around 41 (mm). If I leave out the "*(9/10)", I get 39 which is just the peak, but I need to get to 90% of the peak. Please let me know if you could help! Thank you in advance!
"Depth" is my x data and "SeventyMeV" is my y data.
[TenthmaxYValue, indexAtMaxY] = max(SeventyMeV)*(9/10);
xValueAtMaxYValue = Depth(indexAtMaxY(1))
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/414238/image.jpeg)
0 comentarios
Respuestas (2)
ICR
el 15 de Nov. de 2020
Editada: ICR
el 15 de Nov. de 2020
% Find the max value for your data
maxVal = max(SeventyMeV);
maxVal90 = round(maxVal)*(9/10); % if you have enough datapoints remove round.
% Orelse you can use round or floor whichever suits you
[row,col] = find(SeventyMeV == maxVal90);
valAt90 = SeventyMeV(row(2)); % this will be your value of 90% after the peak
depthAt90 = depth(row);
6 comentarios
Star Strider
el 15 de Nov. de 2020
It would be necessary to have a sample of your data to write specific code, so I will simply describe the procedure.
Second, use the ‘locs’ index values (second output of findpeaks) to determine the indices of the peaks.
v90(k) = interp1(y(locs(k)+[0 1]), x(locs(k)+[0 1]), 0.9*y(pks(k)), 'linear','extrap')
for each peak for k = 1:numel(locs).
I cannot figure out a way to simulate the missing data, so I am labeling this UNTESTED CODE. It should work, however it may need to be tweaked to work with your data.
6 comentarios
Star Strider
el 15 de Nov. de 2020
Again, this is a problem of not having your data to work with.
Solve the NaN probllems by adding 'extrap' to the interp1 call:
v90(k) = interp1(y(locs(k)+[0 1]), x(locs(k)+[0 1]), 0.9*y(locs(k)), 'linear','extrap') % X-Values At 90% After Peak
This may result in ‘interesting’ extrapolated values!
Another option (with or without 'extrap') is:
v90(k) = interp1(y(locs(k)+[0:2]), x(locs(k)+[0:2]), 0.9*y(locs(k)), 'linear') % X-Values At 90% After Peak
However without at least a sample of your data, I’m just left to guess as to what the probllems could be.
I leave it to you to experiment with these options.
Ver también
Categorías
Más información sobre Multirate Signal Processing 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!