How to export data logging in Simcape simulation by second?

조회 수: 6 (최근 30일)
Thanh
Thanh 2025년 3월 25일
답변: Yifeng Tang 2025년 3월 31일
Hello,
I tried to run this Lithium Battery Cell - One RC-Branch Equivalent Circuit. My run time is 36000s but the data logging only has 1150 data. I adjusted model setting solver with max stepsize is 1 but does not help.
Please help! Thank you so much in advance
openExample('simscape/LithiumBatteryCellOneRCBranchEquivalentCircuitExample')

답변 (2개)

TED MOSBY
TED MOSBY 2025년 3월 26일
편집: TED MOSBY 2025년 3월 26일
Hi Thanh,
Missing data points can be due to using a "variable‐step solver" due to which Simulink only saves points at the time steps the solver actually takes. Simply setting “Max step size = 1” may not guarantee you will get 1s–spaced data, because the solver may still choose fewer (larger) steps, especially if the system is not changing rapidly.
To get a uniform output every 1s (or any spacing you want), you can do the following:
Use a fixed‐step solver
  • In Model Settings → Solver, change Type to “Fixed‐step” (instead of “Variable‐step”).
  • Set Solver (e.g., ode4) and Fixed step size to 1s.
  • This ensures Simulink advances exactly in 1s increments and will produce 36001 points over 0–36000s.
  • Under Additional parameters in Data Import/Export, make sure the Limit data points to last is large enough or unchecked if you want all data.
Use a “To Workspace” Block
You can manually place a To Workspace block in your model and double-click it to configure:
  • Sample time: Set it to 1.0 (seconds), so it forces the block to sample at every 1s.
  • Limit data points to last: Make sure this is large enough or unchecked if you want all data.
If you just need a time series at a consistent 1s interval, the simplest approach is to pick a fixed‐step solver with step size = 1s.
Hope it helps!

Yifeng Tang
Yifeng Tang 2025년 3월 31일
First thing to check, whether you are limiting the number of data points to keep. I suspect so, as your tout variable has length of 1000.
It's possible to define a time vector where you want the output to be sampled at. See below.
This applies to logged Simulink signals only. If you use a sensor to measure Simscape values and convert to Simulink signal and log, this still applies. If you are getting data out of simlog, I think the easiest way is to do an interp1 in a post-processing script.
I actually disagree with the "fixed-step" solver approach mentioned in another answer. Variable-step solver is usually faster and more accurate. Interpolating in the region where a larger time step is taken by the variable step solver should be safe. In addition, the model may not give accurate results with the 1sec fixed step.

카테고리

Help CenterFile Exchange에서 Converters (High Power)에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by