To plot the given solution y(t) = ce^(-t) with c = 10 in the range t ∈ [0, 5] and a discretization step ∆t = 0.1 in MATLAB, you can follow these steps:
Define the range of t using the colon operator in MATLAB: t = 0:0.1:5. This will create a vector with values ranging from 0 to 5 with a step size of 0.1.
Calculate the corresponding values of y(t) using the given formula y(t) = ce^(-t). In this case, c = 10. So, you can use the element-wise exponential function in MATLAB, exp(), to calculate y(t): y = 10 * exp(-t).
Plot the obtained values of y(t) against t using the plot() function in MATLAB: plot(t, y).
Here's the MATLAB code that implements the steps mentioned above:
main.m42 chars4 lines
When you run this code in MATLAB, it will plot the graph of y(t) vs t, where t ranges from 0 to 5 with a step size of 0.1 and y(t) is calculated using the formula y(t) = 10 * e^(-t).
gistlibby LogSnag