Hi Donghun,
I understand that you are trying to plot a road profile followed by analyzing the system's response.
While reproducing the provided code on my end in MATLAB R2024b, I found that the potential reason for the system's response as a sinusoidal wave is because the 'ode45' is called inside the 'for' loop, recalculating the system's response at each point in 'x1'.
As a result, the simulation restarts at every step, whereas it should be integrated over the entire time span.
For better understanding, you can refer to the code snippet below:
for iv = 1:length(x1)
h(iv) = sum(Amp .* cos(2*pi*Omega*x1(iv) + Psi));
end
plot(x1, h*1000);
xlabel('Distance (m)');
ylabel('Elevation (mm)');
title('Road Profile');
%% ODE45
T = 110;
x0 = [0, 0];
f = @(t, x) [x(2); -(k_s * (x(1) - 1000 * interp1(x1, h, t)) / m)];
[t, x] = ode45(f, [0, T], x0);
For reference purpose, I have attached the output graph of system's response below :
I hope this resolves the issue.