I have the code for a decaying sinusoid and I want to figure out how to reverse it

조회 수: 1 (최근 30일)
function xs = myDecayingSinusoid(A, b, omega, phi, fs, tStart, tEnd)
A = 6;
b = .9;
omega = 60 .* 2 .* pi;
phi = pi ./ 3;
fs = 15;
tStart = 0;
tEnd = 3;
tt = [tStart:1 / fs: tEnd];
xs = A * exp(-b * tt) .* cos(omega * tt + phi);
plot(tt, xs, 'b-')
end

답변 (1개)

Star Strider
Star Strider 2022년 8월 31일
I have no idea what ‘reverse’ means in this context. If you want to change ‘tt’ the easiest way is to re-code it as:
tt = linspace(tStart, tEnd, 1/Fs)/Fs;
then to revferse it simply reverse the values of ‘tStart’ and ‘tEnd’ in the function call. The linspace function does the rest. If you want to reverse the direction of the x-axis, after the plot call, add:
set(gca, 'XDir','reverse')
And of course, you can do both. Note that changing the linspace arguments alone will not change the plot appearance, because plot always plots with increasing values of the independent (x) variable vector.

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by