Public
Edited
Jun 7, 2023
Insert cell
Insert cell
Insert cell
{
let d = mdl.t.map((v,i)=>{return {time: v, stim: mdl.stim[i]};});
return Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.lineY(d, {x: V=>V.time, y: V=>V.stim, height:200}),
]
})
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
solution = await solve(mdl.odefun,mdl.t,mdl.init,mdl.opt);
Insert cell
Insert cell
chunk = {
const sol = solution.sol;
const time = solution.t[0];
const tspan = [0.15,0.4];
const startIdx = time.reduce((sum, curr, i) => curr <= tspan[0] ? i : sum, 0);
const endIdx = time.reduce((sum,curr,i) => curr <= tspan[1] ? i : sum, 0);
const T1 = math.subset(time,math.index(math.range(startIdx,endIdx,true)));
const y1 = math.subset(sol,math.index(math.range(0,5),startIdx));
const chunk = await solve(mdl.odefun,T1,y1,mdl.opt);
return chunk
}
Insert cell
Insert cell
async function getChunk(soln,tspan){
tspan = tspan.length === 2 ? tspan : [0,...tspan];
const sol = soln.sol;
const time = soln.t[0];
const startIdx = time.reduce((sum, curr, i) => curr <= tspan[0] ? i : sum, 0);
const endIdx = time.reduce((sum,curr,i) => curr <= tspan[1] ? i : sum, 0);
const T1 = math.subset(time,math.index(math.range(startIdx,endIdx,true)));
const y1 = math.subset(sol,math.index(math.range(0,5),startIdx));
const chunk = await solve(mdl.odefun,T1,y1,mdl.opt);
return chunk
}
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more