How can I plot out the derivatives here?

I want to plot out multiple derivatives in my plot, namely dLdt, dWdt, and dNdt. How could I go about it? Whenever I've tried to plot it, I would get a popup window of the graph with no actual graph to display. Please help.
Here's the code:
l0 = 0; % initial height of plant
lf = 5; % final height of plant
w0 = 3; % initial amount of water
wf = 0; % final amount of water
n0 = 3;
nf = 0;
tr = [0 12]; % time in hours
% this is about to get crazy
% plant growth
Y = log(x)
L = ((3*x+2)*log(3*x+2)-3*x)/3
N = -(25*e^(-2*x/5)/2)
W = -(50*e^(3*x/10)/3)
%Time specifications:
Fs = 6400; % samples per second
dt = 1/Fs; % seconds per sample
StopTime = 12; % hours
td = (0:dt:StopTime-dt)'; % seconds
%%Sine wave:
Fc = 0.02; % frequency
S = sin(2*pi*Fc*td);
% Plot the signal versus time:
figure;
plot(td,S);
xlabel('time (in hours)');
syms x
dLdt = diff(L)
dNdt = diff(N)
dWdt = diff(W)

Answers (1)

Either plot the differential equation using the solved values for ‘t’, and the solved values for the integrated variables, and other arguments in a loop.
Or, use the gradient function on the solved variables using the returned ‘t’ vector to plot the derivatives:
dydt = gradient(y) ./ gradient(t);
Both of these work.
.

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 20 May 2021

Answered:

on 20 May 2021

Community Treasure Hunt

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

Start Hunting!