Approximate the first zero crossing of an exponentially decaying waveform.

2 ビュー (過去 30 日間)
Ahmed Mohamed Mansoor
Ahmed Mohamed Mansoor 2021 年 7 月 14 日
回答済み: Yazan 2021 年 7 月 17 日
Trying to answer this question. So part a and b has been accomplished. I am not able to do part c. Can anyone please help me with this.
function p = wave_fction
%q2b
y = 0.1;
t = linspace(0,20,12);
p = ((exp(-y.*t))/sqrt(1-y.^2)).*sin((atan(sqrt((1-y.*2)/y))+t*sqrt(1-y.^2)));
tt = 0:20;
yy = spline(t,p,tt);
figure (1)
plot(t,p,'o',tt,yy),xlabel('x-axis'),ylabel('y-axis')
title ('Spline1')
hold on
m = 0:20;
n = (m\0);
plot (m,n)
hold off
y = 0.1;
t = linspace(0,20,200);
p = ((exp(-y.*t))/sqrt(1-y.^2)).*sin((atan(sqrt((1-y.*2)/y))+t*sqrt(1-y.^2)));
tt = 0:20;
yy = spline(t,p,tt);
figure (2)
plot(t,p,'o',tt,yy),xlabel('x-axis'),ylabel('y-axis')
title ('Spline2')
hold on
m = 0:20;
n = (m\0);
plot (m,n)
hold off
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a = t;
b = p;
c = tt;
figure (3)
vq2 = interp1(a,b,c,'spline');
plot(a,b,'o',c,vq2,':.');
hold on
m = 0:20;
n = (m\0);
plot (m,n)
hold off
xlim([0 20]);
title('Interp1');
err= abs(((1.6794-2)/1.6794)*100)
This is what has been done so far. Please help me complete part (c ) of the question.

採用された回答

Yazan
Yazan 2021 年 7 月 17 日
Looking at the figures that your code produces, you can see clearly that the first zero-crossing is not around 1.6794 as your text suggests, so there is a problem somewhere. Anyways, you can interpolate the t-position of the first zero-crossing using the following.
% find index of first datapoint below zero
idx = find(p<0, 1, 'first');
% 15 query points
tt = linspace(t(idx-1), t(idx), 15);
% You can use any interpolation method you find fitting your problem
pq = interp1([t(idx-1), t(idx)], [p(idx-1), p(idx)], tt);
% find index of first datapoint below zero using interpolated signal
idx2 = find(pq<0, 1, 'first');
% take the midpoint between this point and its above-zero neighbor
tq = mean([tt(idx2-1); tt(idx2)]);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by