Filter löschen
Filter löschen

i have to implement a discrete time derivative. i am a beginner at matlab and need thorough assistance please.

3 Ansichten (letzte 30 Tage)
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

Antworten (1)

Shreeya
Shreeya am 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:
  • 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.
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!

Kategorien

Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by