Random road profile to quarter car model in simulink

조회 수: 50 (최근 30일)
Dito Ata'ul Momin Wicaksono
Dito Ata'ul Momin Wicaksono 2024년 3월 20일
답변: Maneet Kaur Bagga 2024년 10월 9일
Hellow everyone, I am currently doing a project which includes simulating a quarter car model on a random road profile based on ISO 8608. I have coded the road profile in matlab and wanted to input the profile which is a 1 x 2250 data as an input for my quarter car model, but the simulink model includes a derivative and integration blocks so I guess it is why I'm always receiving an error message everytime it runs. Is there anyway I could do this, what I want to do basically is replace the usual sine wave or step function with the data I have generated with matlab.
Thank you in advance, below are my simulink model and matlab code
% Parameters
k = 4; % Values for ISO Road Roughness Classification, from 3 to 9
V = 40; % Car Velocity (km/h)
L = 250; % Length of road profile (m)
N = L / (V / 3.6) * 100; % Number of data points
B = L / N; % Sampling interval (m)
dn = 1 / L; % Frequency band
n0 = 0.1; % Spatial frequency (cycles/m)
% Spatial frequency band
n = dn : dn : N * dn;
% Random phase angle
phi = 2 * pi * rand(size(n));
% Amplitude for Road Class A-B
Amp1 = sqrt(dn) * (2^k) * (1e-3) * (n0 ./ n);
% Abscissa variable from 0 to L in distance and time domain
x = 0 : B : L - B;
t = x ./ (V / 3.6);
% Initialize road profile
hx = zeros(size(x));
% Generate road profile data
for i = 1:length(x)
hx(i) = sum(Amp1 .* cos((2 * pi * n * x(i)) + phi));
end
% Compute Power Spectral Density (PSD) using external file
[q , C] = psd_1D(hx, B, 'x');
lambda = (2*pi) ./ q; % Wavelengths
% Frequency axis
f = q / (2*pi); % spatial frequency
PSD = 2 * pi * C; % power spectrum
log_f = log10(f); % Converts to Logarithmic
log_psd = log10(PSD); % Converts to logarithmic
% Plot road profile
% Plot the road length vs amplitude of the road profile
subplot(2,2,1)
plot(x, hx);
xlabel('Distance (m)');
ylabel('Amplitude (m)');
grid on
% Plot the PSD vs Spatial frequency of the road profile
subplot(2,2,2)
plot(log_f, log_psd);
xlabel('Frequency (cycles/m)');
ylabel('PSD (m^3)');
grid on
% Plot the time vs amplitude of the road profile
subplot(2,2,3)
plot(t, hx);
xlabel('Time (s)');
ylabel('Amplitude (m)');
grid on
simulink model

답변 (1개)

Maneet Kaur Bagga
Maneet Kaur Bagga 2024년 10월 9일
Hi,
As per my understanding the error you are encountering is due to the discrete data that is input directly into "derivative" and "integrator" blocks which expect continuously sampled input. To resolve the encountered steps you can refer to the following steps:
  • Load the road profile data into Simulink using a "From Workspace" block.
% Save road profile as time series data for Simulink
t = (0:length(hx)-1) * B; % Adjust time based on distance and sampling
road_profile = [t' hx']; % 2-column matrix [time, road profile]
  • In your Simulink model, replace the sine wave/step function block with a "From Workspace" block. Set the "Data" parameter of the block to "road_profile" which is the time based representation of the road profile. Set the "Sample Time" to "-1" so that Simulink auto-detects the sample time from the data.
  • For blocks like "integrator" and "derivative" that expect continuous data, please check that your data is appropriately sampled. If your road profile "hx" is too coarse, resample it to finer intervals by interpolating the data. Refer to the following code snippet as example.
% Resample road profile to match solver needs
time_fine = linspace(min(t), max(t), finer_sample_points);
hx_fine = interp1(t, hx, time_fine, 'linear'); % Linear interpolation
  • Use a variable-step solver like "ode45" or "ode15" and set the step size equal to the sampling rate of your road profile data.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Automotive에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by