Saving Timeseries out of Workspace as Matlab file
조회 수: 52 (최근 30일)
이전 댓글 표시
So I have a Simulink Modell which I let run automatically via Matlab Skript. I will load in the Modell different Kp and Ki Values for the PI-Controller. Then I have to look if the System is stabil. This is already working and I also get via eigen-values a clue if it is stabil. I have to save them which I do by ploting them.
But I also have to save some timeseries data which I already get from Simulink into my Matlab Workspace via the [TO Workspace Block]. I cant make leftclick and save as because I doing all this in a loop. So I need a code which allows me to save the Timeseries Data as a Matlab file automatically. Best even a counting one, so I dont overright my older saves just because the all have the same name. I hope someone can help me. I already tried
saveas(timeseriesname,[path.mat]);
I found this Code in the Internet where someone also saved timeseries with it (at least what he said). But for me its not working because of the Error: "Invalid handle".
P.s.: Sorry for my bad english :)
댓글 수: 0
답변 (1개)
Ishaan Mehta
2022년 6월 25일
편집: Ishaan Mehta
2022년 6월 25일
Hi Sascha
As per my understanding, you want to save a variable (containing a timeseries) in a .mat file with a dynamic name.
This can be easily achieved using MATLAB's save function.
Please refer to the following article for more details about the save function: Save workspace variables to file.
You can use the following code as a starting point:
count = 1;
for i = 1:10
filename = "myTimeseriesFile" + string(count);
% get timeseries into the workspace from your simulink model
timeseriesVar = timeseries(1:10); % dummy timeseries for demo
save(filename, 'timeseriesVar');
count = count + 1;
end
Cheers
Ishaan Mehta
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!