Load timeseries data from workspace for non-periodic data
조회 수: 6 (최근 30일)
이전 댓글 표시
I want to load timeseries data from workspace to use as my model inputs. The data is a timeseries, but with points only at the times when the value changes (to make the files more managable - if I save all the samples, the files are huge even though the data is mostly invariant).
For examples:
ts.Time = [0 50]
ts.Data = [1 100]
What I want, is the input to be continuously 1 for times between 0 and 50, and then step change to 100 and continue at this value until the end of the simulation. This has to work irrespective of the simulation time step.
When I load the data and run the model, there only seems to be two choices:
1) If I tick the 'Interpolate data' box then for times when there isn't an exact match, the value of the input is interpolated between available samples. If you take my original example, between times 0 and 50 the input will slowly ramp at each simulation timestep instead of a step change at 50.
2) If I clear the 'Interpolate data' box then the value is only set when the simulation time matches the time value in the timeseries. For other times, the input is set to 0. Again, in my example the input shows two short blips at 0 and 50, but then inserts 0 for other timesteps.
Many thanks
댓글 수: 0
채택된 답변
Paul
2024년 1월 10일
In the Model Configuration parameters,
change the Input field under Load From Workspace from ts to
addsample(ts,'Data',ts.Data(end),'Time',realmax)
추가 답변 (1개)
Jon
2024년 1월 10일
I seem to be able to get the desired behavior using the following code to assign a structure, unchecking the interpolate box, and selecting the hold option for forming output after final value
ts.time = [0;50]
ts.signals.values = [1;100]
also works with ts as a time series
ts = timeseries([1 100],[0 50])
댓글 수: 5
참고 항목
카테고리
Help Center 및 File Exchange에서 Sources에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!