what is the problem in thecode??
Show older comments
global k m1 m2 q1 q2 rw iT;
k=8500; %Stiffness of snatch strap m1=1830; %Mass of bogged car in kg m2=2650; %Mass of 4WD in kg q1=925*(x(2)^2);%bogged car drag in N q2=140*(x(4)^2);%4WD drag in N rw=0.394; %Wheel radius in m iT=15; %Gearbox ratio
t0=0; %Define the starting time of the motion in second tf=20; %Define the ending time of the motion in second x0= [0; 0; 0; 0]; %Define the displacement and velocity of bogged car and 4WD Tf=(Te*iT*4)/(rw*4); %Equation to find total wheel force of 4WD car qT=+q2+BF; %Equation of total drag force
options=odeset('abstol',le-6, 'reltol',le-6); %Define the relative and absolute tolerance [t,x]=ode45('Motion_Function',[t0,tf],x0,options);
figure(1); %Plot a graph in a new window plot(t,x(:,1), 'b',t,x(:,3), 'r'); xlabel('Time (s)'); ylabel('Displacement (m)'); title('Graph of Displacement versus Time'); legend('Displacement of bogged car', 'Displacement of 4WD'); grid on; %Plot the graph of displacement versus time for bogged car and 4WD
figure(2); %Plot a graph in a new window plot(t,x(:,2), 'b',t,x(:,4), 'r'); xlabel('Time (s)'); ylabel('Velocity (m)'); title('Graph of Velocity versus Time'); legend('Velocity of bogged car', 'Velocity of 4WD'); grid on; %Plot the graph of Velocity versus time for bogged car and 4WD Undefined function or variable 'x'
2 Comments
madhan ravi
on 3 Oct 2018
Edited: madhan ravi
on 3 Oct 2018
Select the whole code and press the code button {} also upload Motion_Function.
Chin Kong
on 3 Oct 2018
Answers (1)
madhan ravi
on 3 Oct 2018
Edited: madhan ravi
on 3 Oct 2018
[t,x]=ode45(@Motion_Function,[t0,tf],x0,options);
Use
@Motion_Function
Instead of string
'Motion_Function'
4 Comments
Chin Kong
on 3 Oct 2018
madhan ravi
on 3 Oct 2018
Select the whole code and press the code button your code is not readable
Chin Kong
on 3 Oct 2018
Chin Kong
on 3 Oct 2018
Categories
Find more on Assembly in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!