Info

This question is closed. Reopen it to edit or answer.

How to run a Simulink example by not going through the whole coded tutorial? (mech_moto​rcycle_sta​bility)

1 view (last 30 days)
One of the SimMechanics examples in Simulink models a motorcycle to perform a linear stability analysis on it. This example can be called by entering "mech_motorcycle_stability" in the command window.
The only way to run the code is to double click the top left box to start the example. I would like a way to get the results without having to do that.
I can simply run the Simulink model, and it does what it needs to do, but then when I try and use the results by using the code that the tutorial says you should use:
locus = [];
for i=1:20, % Extract 20 linearizations.
vu = 53.5*(i-1)/19; %Speed range 0 to 53.5 m/s.
disp(['Current speed is: ',num2str(vu)]);
motorcycle_dat %Compute the vertical tire force and tire model coefficients.
[A,B,C,D] = linmod('mech_motorcycle_stability'); %Linearize the dynamics at the specified speed.
locus(:,i) = eig(A); %Define locus of eigenvalues.
end;
echo off;
it does not work because the motorcycle_dat cannot be found (I also have no idea where it comes from). However I know the model works because when you go through the whole tutorial, it produces a root locus plot at the end.
So essentially I am looking to find out where and what "motorcycle_dat" is because I think when I have that, then I can run the code and produce results without having to go through the whole worked tutorial.
(Try enter "mech_motorcycle_stability" without the quotation marks to see what I mean about going "through the whole worked tutorial")

Answers (1)

Steve Miller
Steve Miller on 24 Jun 2021
Hi Nicholas,
The lines of code you have copy/pasted have a typo in them.
It should be mech_motorcycle_data, not motorcycle_dat.
The correct code is visible in >>mech_motorcycle_stability_example.m, which is part of Simscape Multibody First Generation technology and examples, available in earlier releases of Simscape Multibody.
--Steve

Community Treasure Hunt

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

Start Hunting!