필터 지우기
필터 지우기

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by