Skip to content

Instantly share code, notes, and snippets.

View SidhBhat's full-sized avatar
🎯
Focusing

Siddharth Bhat SidhBhat

🎯
Focusing
View GitHub Profile

Electrostatic Fields

These are a collection of Octave scripts to visualise the electric field due to a system of point charges

  • plot electric field lines [field_lines.m][link1]
  • plot the normalised field vectors 2D version [field.m][link2]
  • plot the normalised field vectors,3D version [field.m][link3]

@SidhBhat
SidhBhat / field.m
Last active May 20, 2023 21:31
Ocatve script to Plot the normalised electrostatic field vectors of a system of charges in 3 dimentions
clear all;
clf;
global Q;
global K;
% --------- User Configuration --------- %
%% Charges are defined as structures 'Q' containing two fields 'q' and 'x'
%% specifying the charge and position position is given as a three dimensional
%% row vector Multiple charges can be defined by creation an array of these
%% structures.
%% Define Charges
@SidhBhat
SidhBhat / field.m
Last active May 20, 2023 21:11
Ocatve script to Plot the normalised electrostatic field vectors of a system of charges in 2 dimentions
clear all;
clf;
global Q;
global K;
% --------- User Configuration --------- %
%% Charges are defined as structures 'Q' containing two fields 'q' and 'x'
%% specifying the charge and position position is given as a two dimensional
%% row vector Multiple charges can be defined by creation an array of these
%% structures.
%% Define Charges
@SidhBhat
SidhBhat / field_lines.m
Last active May 20, 2023 21:01
Ocatve script to Plot the electrostatic field lines of a system of charges
clear all;
clf;
global Q;
global K;
global plot_len;
global line_density;
% --------- User Configuration --------- %
%% Charges are defined as structures 'Q' containing two fields 'q' and 'x'
%% specifying the charge and position position is given as a two dimensional
%% row vector. Multiple charges can be defined by creation an array of these
@SidhBhat
SidhBhat / kdev-run.sh
Last active March 30, 2023 04:49
Compile and run interactivly a c/c++ file. Useful for beginners
#! /bin/bash
# You can use this script to compile and run a single file c or cpp program interactively
# the code should be open in a editor, while call this script to execute the code
## I had used this script as an alternative to Turbo++ (which my school had asked me to use)
options=$(getopt -o cphl:d: --long help,language:,directory: -- "$@")
[ $? -eq 0 ] || {
echo -e "\e[1;31mUnexpected Error\e[0m terminating...."
@SidhBhat
SidhBhat / trajectory.m
Created March 26, 2023 22:15
Compute the trajectory of a particle under the gravity of a massive central body
% In this script we find the orbital path a body under gravity.
% The mass of this particle is insignifcant compared to the mass
% of the central body.
% Clear Existing Values
clear all;
clf;
%##------------- Start Configuration ----------------##%