How to extract and to export to Excel some variables that have been logged using To Workspace block?
7 次查看(过去 30 天)
显示 更早的评论
Good morning, I am working with a Simulink model that has been developed by Professor A.Tayyebi et al to implement several Grid-forming control techniques for inverters using the IEEE 9-Bus System as benchmark.
In order to study the dynamic of the inverters I need to monitor changes in the frequency of the system caused by an increase in the power demanded by the loads.
To that end, I am using the “To Workspace” block for logging the frequency values in the model Workspace.
The simulation time is 50 s but I only need to extract the frequency values in the time interval immediately after the increase in the load and for 500 ms, that is, the frequency values between 25 and 25.5 seconds. I intend to export said frequency values to an excel file then.
My questions are the following:
1.- Which would be the most suitable save format to extract these frequency values against time, i.e.:
Structure with time, Structure, Array or Timeseries.?
2.- Which are the most suitable commands to extract the logged time and frequency values and to export them to Excel?
An example of commands would be very welcomed indeed. Thanks in advance!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1458927/image.jpeg)
0 个评论
采纳的回答
Jon
2023-8-17
There are many ways to do this. I have attached a simple example showing one way to do it with the data being saved in timeseries format. Please first run the model, and then run the attached script to demonstate how it works. You should be able to adapt this approach to your specific situation.
Just so you can see it easily, here is the script for saving the data after you run the model
% Script to save output of Simulink To Workspace block
% To Workspace block saves data as TimeSeries
% Convert timeseries to timetable, to make it more convenient to export
TT = timeseries2timetable(out.y)
% Find rows of interest
tr = timerange(seconds(25),seconds(25.5));
% Export the rows of interest
writetimetable(TT(tr,:),'myFile.xlsx')
3 个评论
Jon
2023-8-22
Sorry I didn't see you earlier message. Glad you were able to resolve it by updating to the current MATLAB version. Good luck with your project
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!