Equation plot problem of dy/dx

8 vues (au cours des 30 derniers jours)
buer
buer le 24 Nov 2015
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.

Réponses (2)

Star Strider
Star Strider le 24 Nov 2015
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 le 24 Nov 2015
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.

Community Treasure Hunt

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

Start Hunting!

Translated by