- Prepend zero to u vector to enforce the initial condition.
- Iterate over the vector, starting from the second index using a for loop.
- Evaluate equation 16.
- Store the results in an output vector y.
i have to implement a discrete time derivative. i am a beginner at matlab and need thorough assistance please.
2 views (last 30 days)
Show older comments
Create a new MATLAB m-function of the form function y = num_derivative(u,T) and implement the discrete-time derivative (16). o The function must accept any column vector 𝑢 (=discrete-time input signal) of arbitrary length and a positive real number 𝑇 (=sampling time) as input arguments. o The function must generate a column vector 𝑦 of the same length as the input 𝑢 as output. The first value in 𝑦, which cannot be determined based on the available input samples 𝑢[𝑘], shall be set to zero.
(16) is u[𝑘] ≈ 𝑢[𝑘] − 𝑢[𝑘 − 1] /T
0 Comments
Answers (1)
Shreeya
on 5 Sep 2023
I understand that you want to implement the discrete time derivative using m-function in MATLAB. Given input arguments are u[k], a column vector input with initial value set to zero and T.
You can follow the following steps to construct the function:
Refer to the pseudo code for more details.
function y = discrete_time_derivative(u,T)
y = zeros(size(u))
u = [0;u]
for i = 2:length(u)
y(i) = (u(i)-u(i-1))/T
end
end
Hope this helps!
0 Comments
See Also
Categories
Find more on Loops and Conditional Statements 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!