Azzera filtri
Azzera filtri

Road profile, car model, suspension model

18 visualizzazioni (ultimi 30 giorni)
Mattia Abrate
Mattia Abrate il 10 Mar 2022
Risposto: Divyanshu il 4 Mar 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

Risposte (1)

Divyanshu
Divyanshu il 4 Mar 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.

Categorie

Scopri di più su General Applications in Help Center e File Exchange

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by