drone-rigide/scripts/plot_internal_tun.jl
2019-06-02 18:02:15 +02:00

35 lines
899 B
Julia

using Plots
using CSV
pyplot()
file_measure = "linear_x2.csv"
file_input = "input_linear_x2.csv"
measure = CSV.read(file_measure, header=false) |> Matrix{Float64};
command = CSV.read(file_input, header=false) |> Matrix{Float64};
init_measure = 1
end_measure = 20
init_command = 30
for (i,t) in enumerate(measure[:,1])
global init_measure = i
if t >= command[init_command,1]
break
end
end
plot(
measure[init_measure:end-end_measure,1],
measure[init_measure:end-end_measure,2],
title="plop",
size=(1000, 600)
)
s = sum([x * (measure[init_command + i,1] - measure[init_command + i-1,1]) for (i,x) in enumerate(measure[init_measure:end-end_measure,2])]) / (measure[end-end_measure,1] - measure[init_measure,1])
plot!([measure[init_measure,1], measure[end-end_measure,1]], [s, s])
plot!(
command[init_command:end,1],
command[init_command:end,2]
)
show()