Equation plot problem of dy/dx

5 次查看(过去 30 天)
buer
buer 2015-11-24
回答: Star Strider 2015-11-24
Hi,
I have one problem does not understand. I have an equation for example: Z=A*dB/dt + B*dA/dt . I know A and B, but how can I plot Z? how I can express dA/dt or dB/dt? I tried with diff(A)./diff(t) this give 1 elements less than A. so it make B*dA/dt not possible. can anyone help.
Thanks a lot.

回答(2 个)

Star Strider
Star Strider 2015-11-24
The gradient function will calculate the first derivative, giving a result the same length as the input vector.
For example:
t = linspace(0, 1);
A = exp(-5*t) .* sin(6*pi*t); % Create Function ‘A’
B = cos(exp(-2*t)*2*pi); % Create Function ‘B’
dAdt = gradient(A,t);
dBdt = gradient(B,t);
Z = A.*dBdt + B.*dAdt;
figure(1)
plot(t, Z)
grid
xlabel('t')
ylabel('Z')

Walter Roberson
Walter Roberson 2015-11-24
Z=A*dB/dt + B*dA/dt needs to be understood in terms of symbolic A and B,
Z = A(t) * diff(B(t),t) + B(t) * diff(A(t),t)
with A(t) and B(t) functions, this is of course the same as
Z = diff( A(t) .* B(t), t)
As they are functions, you need to substitute the formulas for the functions into Z. Then you evaluate the resulting formula over the set of t values that you want to plot at.

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by