Last active
December 17, 2021 07:19
-
-
Save scls19fr/172c351557721e8851b828018738b4c0 to your computer and use it in GitHub Desktop.
planeur - polaire - parabole - 3pts ou plus (régression polynomiale)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"hide_input": false | |
}, | |
"outputs": [], | |
"source": [ | |
"using CSV\n", | |
"using DataFrames\n", | |
"\n", | |
"s_dat = \"\"\"v;vz\n", | |
"110;-0.6\n", | |
"150;-1.09\n", | |
"190;-2\"\"\";\n", | |
"\n", | |
"dat = CSV.File(IOBuffer(s_dat)) |> DataFrame" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# dat.v = dat.v * 1000 / 3600 # conversion km/h en m/s\n", | |
"# dat.v = dat.v / 100 # conversion km/h en 1/100ème de km/h" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# import Pkg; Pkg.add(\"Polynomials\")\n", | |
"using Polynomials" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"p = fit(dat.v, dat.vz, 2, var=:v) # régression polynomiale\n", | |
"p" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"println(\"A=$(p[2]) B=$(p[1]) C=$(p[0])\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"v_calc = range(60, stop=260, length=100);\n", | |
"vz_calc = p.(v_calc);" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"using Plots" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"plot(dat.v, dat.vz, seriestype=:scatter, title=\"Polaire\")\n", | |
"plot!(v_calc, vz_calc)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Julia 1.6.1", | |
"language": "julia", | |
"name": "julia-1.6" | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"mimetype": "application/julia", | |
"name": "julia", | |
"version": "1.6.1" | |
}, | |
"widgets": { | |
"application/vnd.jupyter.widget-state+json": { | |
"state": {}, | |
"version_major": 2, | |
"version_minor": 0 | |
} | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = "PolarCurve" | |
license = "MIT" | |
authors = ["Sébastien Celles <s.celles@gmail.com>"] | |
version = "0.0.1" | |
[deps] | |
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" | |
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" | |
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" | |
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Render with NBViewer