Road profile, car model, suspension model

15 visualizaciones (últimos 30 días)
Mattia Abrate
Mattia Abrate el 10 de Mzo. de 2022
Respondida: Divyanshu el 4 de Mzo. de 2024
Hi everyone I made this MATLAB code in order to generate random road profiles starting from the corresponding PSD value:
psi0=1;
plot1=1;
L=100;
L1=0; %start length of the road
L2=L1+L; %end of the road (m)
psi0=psi0*10^-6;
omega1=.01; %low cutoff wavenumber for PSD
omega2=100; %high cutoff wavenumber
delta=omega1; %step size
N=((omega2-omega1)/delta)+2; %number of points in PSD plot
omega=linspace(omega1,omega2,N); %psd plot wavenumber range
psi=zeros(1,N); %initialize PSD
Ns=100; %number of samples in one meter of road profile
s=L1:1/Ns:(L2-1/Ns); %road profile range
z=zeros(1,Ns*L2); %initialize road
a=zeros(1,N); %initialize amplitude
phi=rand(1,N)*2*pi; %random angles
W=2; %waviness
psi(1:N)=psi0*(omega(1:N).^(-W)); %Calculate PSD
a(1:N)=(2*psi(1:N)*(delta)).^(1/2); %Calculate amplitude
for i=1:Ns*L2
for j=1:N
z(i)=(a(j)*sin((omega(j)*s(i))-phi(j)))+z(i);
end
end
z(1:Ns*L2)=z(1:Ns*L2)-z(1); %fix initial conditions to 0
if plot1==1
figure
subplot(2,1,1);
loglog(omega,psi)
title('PSD of road profile');
xlabel('wavenumber (rad/m)');
ylabel('PSD m^2/(rad/m)');
subplot(2,1,2);
plot(s,z*100);
title('road profile');
xlabel('road longitudinal axis (m)');
ylabel('road vertical ondulations (cm)');
set(gcf,'color','w');
end
The code works pretty nicely and here is an example of an obtained plot:
Now, I'm trying to use it as an input for the suspension simulink model, I used the blocks: MATLAB function and interpreted MATLAB functions, in both the cases, the solving time is really high and the plot I obtained has the following form:
It looks as Simulink is not able to interprete the for cycle and it recalculates the whole profile for each time step, also if I run the model again I obtain always the same output, while in MATLAB I obtain a different profile every time I run the code.
Can someone help me to solve this??
Thanks,
Mattia

Respuestas (1)

Divyanshu
Divyanshu el 4 de Mzo. de 2024
Hi Mattia,
I created a dummy model, with only MATLAB Function Block and placed the above code inside the block.
On Simulation, I was able to get multiple different profiles correctly as expected. Therefore, the Simulation with MATLAB Function block is working as desired and probably the other parts/blocks of the Suspension model are affecting the final plot.

Categorías

Más información sobre General Applications en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by