diff --git a/c_runtime/ModelicaExternalC/ModelicaTablesImpl.c b/c_runtime/ModelicaExternalC/ModelicaTablesImpl.c index e153a1c86f6..ca8ac01bd3f 100644 --- a/c_runtime/ModelicaExternalC/ModelicaTablesImpl.c +++ b/c_runtime/ModelicaExternalC/ModelicaTablesImpl.c @@ -54,7 +54,7 @@ int ModelicaTables_CombiTable1D_init(const char* tableName, const char* fileName double const *table, int nRow, int nColumn, int smoothness) { - return omcTableTimeIni(0.0, 0.0, smoothness, 2 /* extrapolate based on two first/last values */, tableName, fileName, table, nRow, nColumn, 0); + return omcTableTimeIni(*table, *table, smoothness, 2 /* extrapolate based on two first/last values */, tableName, fileName, table, nRow, nColumn, 0); } void ModelicaTables_CombiTable1D_close(int tableID) diff --git a/c_runtime/tables.cpp b/c_runtime/tables.cpp index b180ec8f7c4..6bda21a8cd6 100644 --- a/c_runtime/tables.cpp +++ b/c_runtime/tables.cpp @@ -645,15 +645,17 @@ double InterpolationTable::interpolate(double time, size_t col) const if (!data) return 0.0; // substract time offset - time -= startTime; + //fprintf(stderr, "time %g startTime %g\n", time, startTime); - if (time < 0.0) + if (time < minTime()) return extrapolate(time,col,time <= minTime()); - for(size_t i = 1; i < lastIdx; ++i) + for(size_t i = 0; i < lastIdx; ++i) { + //fprintf(stderr, "getElt: %d %g->%g\n", i, getElt(i,0), getElt(i,1)); if (getElt(i,0) > time) { return interpolateLin(time, i-1,col); } + } return extrapolate(time,col,time <= minTime()); } bool InterpolationTable::compare(const char* fname, const char* tname,