フィルターのクリア

Derivative of t when t is a number

1 回表示 (過去 30 日間)
Philosophaie
Philosophaie 2013 年 9 月 13 日
If t is a number. How do you take the derivative of t and get a numerical result without using syms?
x = 5*t^2 - 4*t + 6
t = 1
r = diff(x, t)
It gives the answer:
r =
[]

回答 (1 件)

Image Analyst
Image Analyst 2013 年 9 月 13 日
Make t and array then evaluate x with .^ instead of ^. Then take diff and look at the element where t=1.
  6 件のコメント
Philosophaie
Philosophaie 2013 年 9 月 13 日
編集済み: Philosophaie 2013 年 9 月 13 日
You are telling me that there is no way to substitute a number value for a syms variable.
syms t
x = 5*t^2 - 4*t + 6
r = diff(x, t)
then after you take the derivative of x into r there is no way of subtituting a number value for t.
Image Analyst
Image Analyst 2013 年 9 月 13 日
I don't think you understand digital/quantized numerical analysis. Sure, the derivative is 10*t-4, which evaluates to -4 at t=0, and 6 at t=1, but when you've quantized it to only the nearest 1 for t, then you don't get the exact derivative. The slope is delta_x / delta_t as delta_t goes to zero, right? Now, if you're quantized so that you only have samples at t=0,1,2,3,4 then you're never going to be able to get that slope because you're too far away. You're getting sort of the average slope over that huge distance. Here, look at this code where I decreased the distance (increased the sampling rate). If you run this code and analyze it at t=1 you'll see you get very close to a derivative (slope) of 6, which is the theoretical answer.
t=0:.001:2;
x = 5 * t .^ 2 - 4 .* t + 6;
delta_x = diff(x);
% Evaluate at t = 1
% First, need to find the index where t = 1.
t1Index = find(t == 1)
% Now evaluate the slope there
slope = delta_x(t1Index) / (t(t1Index) - t(t1Index-1))
% t1Index =
% 1001
% slope =
% 6.00499999999914
If you make the steps in t even smaller, you'll get even closer. Does that explain it better?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by