Determine intercept of two Lines
14 次查看(过去 30 天)
显示 更早的评论
Good afternoon,
I've developed the following data set, interpolating a line in a data set and looking to determine the points in which the interpolated data intercepts with a horizontal value. Relativly new to Mathlab, so this is most likely not the most concise approach. Thanks in advance for any advice or word of wisdom.
f = [1.337 1.378 1.4 1.417 1.438 1.453 1.462 1.477 1.487 1.493 1.497 1.5 1.513 1.52 1.53 1.54 1.55 1.567 1.605 1.628 1.658];
a = [.68 .9 1.15 1.5 2.2 3.05 4 7 8.6 8.15 7.6 7.1 5.4 4.7 3.8 3.4 3.1 2.6 1.95 1.7 1.5];
xq = 0:.01:1.7
hp = (1/sqrt(2))*a_max
figure
vq1 = interp1(f,a,xq);
plot(f,a,'ob',xq,vq1,':.')
hold on;
yline(hp,'b--')
xlabel('Frequency, Hz')
ylabel('Acceleration, 10^-3 g')
%Natural Frequency
[a_max, index] = max(a);
f_n = f(index)
采纳的回答
Voss
2022-2-25
编辑:Voss
2022-2-26
You can do another interpolation (actually two interpolations), splitting the curve into two parts: before the peak and after the peak. Treat acceleration as x (independent variable) and frequency as y (dependent variable) in the interpolations, in order to find which frequency corresponds to acceleration hp in each part of the curve.
f = [1.337 1.378 1.4 1.417 1.438 1.453 1.462 1.477 1.487 1.493 1.497 1.5 1.513 1.52 1.53 1.54 1.55 1.567 1.605 1.628 1.658];
a = [.68 .9 1.15 1.5 2.2 3.05 4 7 8.6 8.15 7.6 7.1 5.4 4.7 3.8 3.4 3.1 2.6 1.95 1.7 1.5];
xq = 0:.01:1.7
[a_max, index] = max(a);
hp = (1/sqrt(2))*a_max
vq1 = interp1(f,a,xq);
% finding the frequencies where hp occurs, using the original data:
% f_hp = [0 0];
% f_hp(1) = interp1(a(1:index),f(1:index),hp);
% f_hp(2) = interp1(a(index:end),f(index:end),hp);
% finding the frequencies where hp occurs, using the interpolated data:
nan_vq = isnan(vq1); % first, need to remove extrapolated data (NaNs)
vq1_temp = vq1(~nan_vq);
xq_temp = xq(~nan_vq);
[~,index_vq] = max(vq1_temp); % the rest is the same
f_hp = [0 0];
f_hp(1) = interp1(vq1_temp(1:index_vq),xq_temp(1:index_vq),hp);
f_hp(2) = interp1(vq1_temp(index_vq:end),xq_temp(index_vq:end),hp);
figure();
plot(f,a,'ob',xq,vq1,':.')
hold on;
yline(hp,'b--')
plot(f_hp,[hp hp],'ok','LineWidth',2,'MarkerSize',9)
xlabel('Frequency, Hz')
ylabel('Acceleration, 10^-3 g')
%Natural Frequency
f_n = f(index)
2 个评论
Voss
2022-2-26
No problem.
By the way, I would do it the way that's commented out in my answer, interpolating from the original data (f and a), not interpolating from the interpolated data (xq and vq1). (I left the xq/vq1 version uncommented because that was the phrasing of the question.)
I only mention it because the f/a version is a simpler and easier to understand, but the answers from one method vs the other should be very close. Let me know if you have any questions about it.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!