mirror of
https://gitlab.com/MisterBiggs/julia-for-matlabbers.git
synced 2025-06-16 07:06:48 +00:00
Initial commit
This commit is contained in:
commit
ab4d2d0db4
57
intro.jl
Normal file
57
intro.jl
Normal file
@ -0,0 +1,57 @@
|
||||
### A Pluto.jl notebook ###
|
||||
# v0.14.7
|
||||
|
||||
using Markdown
|
||||
using InteractiveUtils
|
||||
|
||||
# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
|
||||
macro bind(def, element)
|
||||
quote
|
||||
local el = $(esc(element))
|
||||
global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : missing
|
||||
el
|
||||
end
|
||||
end
|
||||
|
||||
# ╔═╡ 7d7820ff-c0f5-41ee-be29-5006e7f4361d
|
||||
begin
|
||||
import Pkg
|
||||
|
||||
# Pkg.add("PlutoUI");
|
||||
using PlutoUI
|
||||
# Pkg.add("Plots")
|
||||
using Plots
|
||||
end
|
||||
|
||||
# ╔═╡ bb461e00-c0aa-11eb-2c7d-1bd1591779c6
|
||||
md"""
|
||||
# Julia for People That Were Unfortunate Enough to Learn MATLAB
|
||||
|
||||
Julia is an incredily performant _(2 order of magnitude faster than Matlab)_, Dynamic _(Date types dont need to be declared unlike C)_, Composable _(The compiler is smart enough to allow functions you write to work for multiple different types of data)_, and most importantly for our use case Julia has very simple syntax that focuses on engineering / science applications.
|
||||
|
||||
> The code in this notebook is running in something called Pluto.jl. Pluto notebooks are similar to Matlab Livescript but have a stricter focus on cells and are immutable meaning that a variable can only be declared once and cannot be changed in other cells. This feels very restricting at first but guarantees that the code you are currently looking at is correct, and allows reactive updating of dependant code. It's important to note that these are Pluto.jl features and not Julia features.
|
||||
"""
|
||||
|
||||
# ╔═╡ 11ed58ac-1289-4b64-88a8-17cb7f0b6cd2
|
||||
md"""
|
||||
## Things Matlab Does Really Weirdly that no one Else Does.
|
||||
|
||||
A major pain point for large Matlab projects is managing installed Toolboxes and Packages. In Matlab once something is installed its available globally and doesn't require being added to a file. There are quite a few downsides to this the largest in my opinion being that its very easy to crowd your namespace. To make it even worse Matlab usually doesn't even warn you about the issue so if two packages offer a function of the same name its just going to choose one and hope it works out. Another big issue this can cause is version conflicts, this is why theres so many issues trying to run code between Matlab versions.
|
||||
|
||||
Julia has a very intuitive package manager. For our uses I won't dig into version management or enviroments since they aren't really needed for smaller projects.
|
||||
|
||||
The best way to install packages is to open the Julia REPL (basically Matlabs command window) and press `]` which puts you in Package mode. You can then `add`, `update` or `remove` packages. You can then press backspace to return to the normal REPL. Once a package is added to Julia you have to bring it into your enviroment to use it by using the `using` keyword. Below is an example that add `PlutoUI` to make Pluto more reactive, and `Plots` which is Julias very powerful plotting library.
|
||||
"""
|
||||
|
||||
# ╔═╡ a6ea55b5-3d1e-4f3c-8b5b-bb6138b6b316
|
||||
@bind x Slider(1:5, show_value=true)
|
||||
|
||||
# ╔═╡ 863587ab-5ead-4ad0-839f-09e798bc6c93
|
||||
plot(y -> y^x)
|
||||
|
||||
# ╔═╡ Cell order:
|
||||
# ╠═bb461e00-c0aa-11eb-2c7d-1bd1591779c6
|
||||
# ╠═11ed58ac-1289-4b64-88a8-17cb7f0b6cd2
|
||||
# ╠═7d7820ff-c0f5-41ee-be29-5006e7f4361d
|
||||
# ╟─a6ea55b5-3d1e-4f3c-8b5b-bb6138b6b316
|
||||
# ╟─863587ab-5ead-4ad0-839f-09e798bc6c93
|
Loading…
x
Reference in New Issue
Block a user