Equation plot problem of dy/dx
5 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(2 个)
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')
0 个评论
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!