Skip to content

Instantly share code, notes, and snippets.

View paulnakroshis's full-sized avatar

Paul Nakroshis paulnakroshis

View GitHub Profile
@paulnakroshis
paulnakroshis / LsqFitExample.jl
Created April 3, 2023 17:21
Example usage of LsqFit.jl
"""
fit_data(model, tdata, ydata, p0)
Fit the model function `model` to the data `ydata` at time points `tdata`
using initial parameters `p0`.
# Arguments
- `model::Function`: The model function to fit.
- `tdata::Vector`: A vector of time points.
- `ydata::Vector`: A vector of corresponding data points.
@paulnakroshis
paulnakroshis / VecVec_to_Array
Last active February 2, 2023 17:54
Vector of Vectors to Array
"""
# Convert a vector of vectors to an array
This function assumes that each vector is the same length;
i.e.
v1 = [ [1,2], [2,3], [5,6] ] # this is fine
v2 = [ [1,2,8], [2,3], [5,6] ] # this is not fine
Example of usage:
```
vv = [[1,2,3], [4,5,6], [7,8,9],[12,13,14]]
@paulnakroshis
paulnakroshis / Plot_Import_Header
Created February 1, 2023 02:00
General Julia Import Header #Julia #Plots.jl #GR #LaTeXStrings #plot config
using Plots
gr()
using LaTeXStrings, Measures
default(fontfamily = "Computer Modern", size=(800,500), titlefont = (16), legendfontsize = 10,
guidefont = (16, :darkgreen), tickfont = (12, :black),
framestyle = :box, yminorgrid = true)
plot([sin, cos], -2π, 2π, label = [L"\sin(θ)" L"\cos(θ)"],
linewidth = 2, linealpha=0.7, legend = :outertopright)
plot!(xticks = ([-2π:π:2*π;], ["-2π", "-π", "0", "π", "2π"]))