我試圖整合功能F其定義爲: function F
x = -3:0.1:3;
F = zeros(1, length(x));
for i = 1:length(x)
if (1.4<= x(i)) && (x(i) <= 1.6)
F(i) = x(i).^2;
else
F(i) = 2;
end
我試圖讓包括3個指數函數的複合函數: rm(list=ls())
library(mosaic)
library(ggplot2)
# 3 functions
NVent=makeFun(161*exp(-x/51028)~x) # from x [0;259200[
Vent3_4=makeFun(1262*exp(-x/48398)~x) # from x [0;345600[
我已經使用How to apply piecewise linear fit in Python?這個問題中發現的一些代碼來執行具有單個斷點的分段線性近似。 的代碼如下: from scipy import optimize
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
x = np.array