interpolation for 2 numbers

2 次查看(过去 30 天)
If i have an image something like this I want to know the 0.98th value of max power. That occurs on either side of the curve. How can I get the corresponding X-axis for 0.98*max_power.
max_power = 523.6947
  2 个评论
Star Strider
Star Strider 2017-1-7
I have no idea what you want.
Please put a ‘+’ or something on the curve that shows what you want to estimate. Also, it would help if you attach your data as a ‘.mat’ file so we can work with it.
sri satya ravi
sri satya ravi 2017-1-7
Please look at the data...... I also attached a figure explaining what i wanted..I want to find the interpolated x values at the condition (0.98*max) indicated by 2 red marks in the figure.
Thanks

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2017-1-7
Here you go:
The Code
D = load('sri satya ravi matlab.mat');
RPM = D.RPM;
Power = D.Power;
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
Pwr98Idx = zci(Power - 0.98*max(Power));
for k1 = 1:numel(Pwr98Idx)
RPMPwr98(k1) = interp1(Power(Pwr98Idx(k1)+(-1:1)), RPM(Pwr98Idx(k1)+(-1:1)), 0.98*max(Power), 'linear');
end
figure(1)
plot(RPM, Power)
hold on
plot(RPMPwr98, [1 1]*0.98*max(Power), 'rp', 'MarkerFaceColor','g')
hold off
grid
celtxt = regexp(sprintf('RPM = %.1f\n', RPMPwr98), '\n', 'split');
text(RPMPwr98, [1 1]*0.98*max(Power), celtxt(1:end-1), 'HorizontalAlignment','center', 'VerticalAlignment','bottom')
The Plot
The code is simple and straightforward, so I did not comment-document it. See the documentation on the individual functions for the details on how to use them.
The only special function is my ‘zci’ anonymous function. It detects zero crossings here by subtracting 98% of the maximum power from the power vector to create the zero-crossing indices, that are negative values in a vector (created by multiplying the vector by a 1-position shifted version of itself) that is otherwise positive. It then uses those indices to determine where to centre the interpolation, does the interpolation, and stores the results in the ‘RPMPwr98’ vector.
Experiment with the code and the function to see how it works.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by