How can I tackle basic calculus on MATLAB?

조회 수: 1 (최근 30일)
Andy
Andy 2022년 12월 9일
답변: Sai 2022년 12월 28일
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