ํ•„ํ„ฐ ์ง€์šฐ๊ธฐ
ํ•„ํ„ฐ ์ง€์šฐ๊ธฐ

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

์กฐํšŒ ์ˆ˜: 3 (์ตœ๊ทผ 30์ผ)
Abdelrhman Haggy
Abdelrhman Haggy 2022๋…„ 6์›” 1์ผ
๋‹ต๋ณ€: Shreeya 2023๋…„ 9์›” 5์ผ
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

๋‹ต๋ณ€ (1๊ฐœ)

Shreeya
Shreeya 2023๋…„ 9์›” 5์ผ
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!

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ MATLAB Coder์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

Community Treasure Hunt

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

Start Hunting!

Translated by