How can I tackle basic calculus on MATLAB?

1 次查看(过去 30 天)
A manufacturer of luxury cars would like to investigate an automatic system for smooth braking. From data collected from professional drivers, they have determined that the following equation describes a good starting point for the desired velocity as a function of time.
where
Note that and T are randomly generated.
Implement a MATLAB function that takes time t, and T as inputs and returns acceleration, a, velocity, v, and displacement, x. Write your function so that it works also when t is a vector of values. Remember that if displacement is x, then velocity and acceleration.
  1 个评论
Rik
Rik 2022-12-9
You can find guidelines for posting homework on this forum here. If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks). If your main issue is with understanding the underlying concept, you may consider re-reading the material you teacher provided and ask them for further clarification.

请先登录,再进行评论。

回答(1 个)

Sai
Sai 2022-12-28
I understand that you are trying to implement a MATLAB function which determines and returns displacement(x), velocity(v) and acceleration(a) from the given time dependent equation taking t and T and v_0 as inputs. I hope the following code snippets helps you for better understanding and getting the expected output.
function [x,v,a] = basic_calculus(v_0,t,T)
v = v_0*(1 - ((t/T).^4)).^2;
a = diff(v);
v1 = @(t) v_0*(1 - ((t/T).^4)).^2;
x = integral(v1,0,max(t));
end
The above snippet contains the called function. Below code snippet contains the calling function. Both are saved in different '.m' files
t = 0:0.1:10;
[x,v,a] = basic_calculus(rand(),t,rand())
Refer to the below documentation links for more information on writing functions in MATLAB, and using 'diff', 'integral'.

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by