Lightning strike simulation

Lightning strike simulation, wave coded in Python and it's possible to call it in Matlab Simulink

You are now following this Submission

Lightning strike simulation, wave coded in Python and it's possible to call it in Matlab Simulink:
Code:
import numpy as np
import matplotlib.pyplot as plt
from tkinter import Tk, Button, Label, Frame
import matplotlib.animation as animation
def simulate_lightning_strike():
# Simulating lightning strike coordinates
x = np.random.uniform(-10, 10)
y = np.random.uniform(-10, 10)
return x, y
def plot_strike(x, y):
# Plotting lightning strike
plt.scatter(x, y, color='red', marker='x')
plt.xlim(-20, 20)
plt.ylim(-20, 20)
plt.xlabel('X')
plt.ylabel('Y')
plt.title('Lightning Strike')
plt.grid(True)
def generate_strike():
x, y = simulate_lightning_strike()
plot_strike(x, y)
# GUI setup
root = Tk()
root.title("Lightning Strike Simulation")
root.geometry("200x100")
frame = Frame(root)
frame.pack()
btn_generate = Button(frame, text="Generate Strike", command=generate_strike)
btn_generate.pack(side="left")
btn_exit = Button(frame, text="Exit", command=root.destroy)
btn_exit.pack(side="left")
# Animation setup
fig, ax = plt.subplots()
ax.set_xlim(-20, 20)
ax.set_ylim(-20, 20)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_title('Lightning Strike Animation')
ax.grid(True)
line, = ax.plot([], [], 'ro-', animated=True)
def animate(i):
x, y = simulate_lightning_strike()
line.set_data(x, y)
return line,
ani = animation.FuncAnimation(fig, animate, frames=100, interval=100, blit=True)
plt.show()
root.mainloop()

Cite As

Mohamed Kbaier (2026). Lightning strike simulation (https://in.mathworks.com/matlabcentral/fileexchange/166086-lightning-strike-simulation), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0