Python Forum
how can I create a recursive graphic with matplotlib
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how can I create a recursive graphic with matplotlib
#1
hello to all, I am wanting to draw a graph similar to the one that will be shown in the image:
[Image: pn40p977hfmefb67g.jpg]
The question is:

  1. For the differential equations given below, solve the sequence and [n], use the program recur for
    0 <= n <= 10, and plot and against n in a stem graph.
  • y[n] = y[n-1] + u[n-1],
    y[1] = 0
I was thinking about using the following numpy libraries in matplotlib.
np.linspace
plt.stem
my problem lies in recur (), well I have information on how it works, for example

[Image: cofo8uaz8yqgaaa7g.jpg]
Reply
#2
Can you explain the context? Are you trying to translate a matlab book into python? Is this homework?
Reply
#3
(Nov-22-2018, 07:49 AM)Gribouillis Wrote: Can you explain the context? Are you trying to translate a matlab book into python? Is this homework?
No,rather it is a challenge that I proposed, look at something that I have been able to do.
import matplotlib.pyplot as plt
import numpy as np
#------------------
ni = 10
a = -0.5
b = np.zeros(ni+1)
n = np.arange(ni+1)
y0 = 1
x0 = 0
x = np.zeros(ni+1)
y = np.zeros(n+1)
y[0] = y0
#----------------
#for i in range(y0-1,ni+1):   --->             |perfect 0 to 10
#    y[i] = a + b[i]+ n[i] + x[i] + x_0 + y_0  |this part I can not interpret it

#markerline, stemlines, baseline = plt.stem(x, y, '-.')
# setting property of baseline with color red and linewidth 2
#plt.setp(baseline, color='r', linewidth=2)
#plt.show()
Reply
#4
I think it is the first order explicit Euler method for solving ordinary differential equations. You can find implementations online, for example at Rosetta code. In your case, the mathematical function f(t, y(t)) would be y(t) + u(t).
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question I’m trying to create a Power BI Matplotlib quadrant chart and I’m a little stumped. Nidwolff 1 325 Mar-04-2024, 06:07 AM
Last Post: Danishhafeez
  matplotlib.pyplot functions create new figures instead of applying to the current one karkas 2 2,044 Jul-09-2020, 08:32 AM
Last Post: karkas
  How to create matplotlib subplots from figures vitaly 3 3,087 Mar-02-2020, 12:58 AM
Last Post: scidam
  Matplolib graphic from batch achilledue 2 2,488 Sep-11-2019, 08:43 AM
Last Post: buran
  how can I create graphics using matplotlib royer14 8 4,144 Nov-21-2018, 07:02 AM
Last Post: Gribouillis
  3D graphic lollie 2 2,758 Jun-11-2018, 07:21 AM
Last Post: lollie

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020