Determine intercept of two Lines

조회 수: 10 (최근 30일)
Daniel Murphy
Daniel Murphy 2022년 2월 25일
댓글: Voss 2022년 2월 26일
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
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
xq = 1×171
0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900
[a_max, index] = max(a);
hp = (1/sqrt(2))*a_max
hp = 6.0811
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)
f_n = 1.4870
  댓글 수: 2
Daniel Murphy
Daniel Murphy 2022년 2월 26일
Thanks, I'm stepping through your code now to understand it for next time. Thanks for taking the time out of your day to help.
Voss
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개)

카테고리

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