Skip to content

Instantly share code, notes, and snippets.

View MShirazAhmad's full-sized avatar

Shiraz Ahmad MShirazAhmad

View GitHub Profile
@MShirazAhmad
MShirazAhmad / clipping.m
Created February 2, 2020 07:18
Normalizing Array to Unity
function norm = norm2unity(input)
norm=(input-min(input))/(max(input)-min(input))
end
@MShirazAhmad
MShirazAhmad / PeaksIndices.m
Last active February 2, 2020 07:33
To Find peaks and corresponding index numbers in array
function [pks,locs,index] = PeaksIndices(Y1,X1)
[pks,locs] = findpeaks(Y1,X1);
for i=1:length(pks);
index(i)=find(Y1==pks(i) & X1==locs(i));
end
end
@MShirazAhmad
MShirazAhmad / clipping.py
Created February 2, 2020 12:12
Clipping raw data on two levels and normalizing to unity
import numpy as np
def clipping(data):
temp = data
cond_zero = (temp <= 0.7) & (temp <= 1.5)
cond_one = (temp >= 0.7) & (temp >= 1.5)
temp[cond_zero] = 0
temp[cond_one] = 1
return temp
@MShirazAhmad
MShirazAhmad / indices.py
Created February 2, 2020 12:15
Finding indices and time stamps of raw data
import numpy as np
def indices(CH, time):
k = 0
i = 0
T = []
while i < (len(CH) - 2):
if CH[i] == 0 and CH[i + 1] == 1 and CH[i + 2] == 1:
T.append(time[i + 1])
k = k + 1
@MShirazAhmad
MShirazAhmad / err.py
Created February 2, 2020 12:16
Error analysis
def Uaddition(Ux,Uy):
import numpy as np
return np.sqrt(Ux**2 + Uy**2)
def Ufraction(X,Ux,Y,Uy):
import numpy as np
return np.sqrt((Ux/Y)**2 + ((X*Uy)/(Y**2))**2)
@MShirazAhmad
MShirazAhmad / Matrix.m
Last active February 3, 2020 04:44
Reflection and Transmission of Light from Multilayer Films: MATLAB Functions
function m = Matrix(Phi,Z)
Limit=length(Phi);
M1=[1 0;0 1];
for j=2:Limit
M{j} = [cosd(Phi(j)) (1i*sind(Phi(j)))/Z(j) ; 1i*Z(j)*sind(Phi(j)) cosd(Phi(j))];
M1=M1*M{j};
end
m=M1;
end
//TrapozoidRule
#include<iostream>
#include<cmath>
#define f(x)(sin(x))
using namespace std;
int main()
{
float a,b,sum,n,h;
int i;
cout<<"Enter Initial Limit of x (a):";
//Simpson's1/3rule
#include<iostream>
#include<cmath>
#define f(x)(sin(x))
using namespace std;
int main()
{
float a,b,sum,n,h;
int i;
cout<<"Enter Initial Limit of x (a):";
@MShirazAhmad
MShirazAhmad / MatricesMultiplication.cpp
Last active February 2, 2020 16:33
2x2 Matrices Multiplication (C++)
///2x2 Matrices Multiplication
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a[5][5],b[5][5],c[5][5],m,n,p,q,i,j,k;
cout<<"Enter rows and columns of first matrix:";
cin>>m>>n;
'''
File name: PhysPlot.py
Authors: Muhammad Shiraz Ahmad and Sabieh Anwar
Date created: 8/20/2019
Date last modified: 1/13/2020
Script Version: 1.1.3 (Stable)
Python Version: 3.7.3
https://github.com/MShirazAhmad/PhysPlot
'''
import webbrowser