In: Mechanical Engineering
Use MATLAB to plot the functions u = 2 log10(60x + 1) and υ = 3 cos(6x) over the interval 0 ≤ x ≤ 2. Properly label the plot and each curve. The variables u and represent speed in miles per hour; the variable x represents distance in miles.
Write the functions,
u = 2log10(60x + 1)
v = 3cos(6x)
The domain of the functions is 0 ≤ x ≤ 2.
Two-dimensional line plots can be created using the ‘’plot function’’.
Firstly define displacement (x) as a vector, next define the function u and then plot the given function by using plot ().
Use hold command to add another plot u to an existing figure.
Input the following into Matlab:
>> x=0:0.01:2;
u=2^log10(60*x+1);
plot(x,u)
hold on
v=3*cos(6*x);
plot(x,v,’r:’)
ylabel(‘Speed(mi/hr)’), xlabel(‘Distance x (mi)’)
legend(‘u’,’v’)
Note: 'r:' string is used for red dotted line.
The output of the plots is as shown below:
Write the functions,
u = 2log10(60x + 1)
v = 3cos(6x)
The domain of the functions is 0 ≤ x ≤ 2.