Thank you guys for the reply.
I understand the solution you've mentioned. Basically we increase the step size to increase the accuracy, like change
sin(0.1)
to
sin(0.01), sin(0.02), ...
to sample more points.
However my case is a little different. I am doing a control simulation, so the formula is like:
1 2 3 4
|
for (size_t k = 0; k < FINAL_STEP; ++k) {
u[k] = K*x[k];
x[k+1] = A*x[k] + B*u[k];
}
|
where K, A, B are constant matrix.
If I want to simulate 10 seconds, and sampling is 0.1s, then
FINAL_STEP
will be 100. Now I want to simulate still in 10 seconds, but more "smoothly", so I change sampling to 0.01s.
What I want to see is a more smooth curve. But if change
FINAL_STEP
to 1000, then the results will be "condensed". In other words,
x, u
will reach the same results in only 1 second, not 10 seconds with more smoothness.
Since the system is already discretized, the index
k
is an integer instead of float/double. Then how can I smoothen my simulation?
Again, thanks a lot for the suggestions.