필터 지우기
필터 지우기

Data Extraction from SimBiology Simulations

조회 수: 17 (최근 30일)
Andrew Heitman
Andrew Heitman 2019년 5월 16일
댓글: Fulden Buyukozturk 2024년 6월 27일 22:24
What is the BEST way to get the simulation data out of simbiology and into excel or some other program?
I have found a brief explanation on how to export to Matlab area and then convert to XLS but its not working terrible well
  댓글 수: 1
Anh-Dung Le
Anh-Dung Le 2020년 4월 8일
I have matlab 2020a now and the simbiology that comes with it is slightly different 2018. However, you can export it to Matlab file and then view the data from there. My problem is the data size isn't large enough and I don't know to increase it. It gives me 70x1 (ie. 70 time units) and the simulations should give alot more if I'm going to export it into excel and use it another graphing platform. Does anyone know how to increase the data size for the simulation?

댓글을 달려면 로그인하십시오.

채택된 답변

Sietse Braakman
Sietse Braakman 2019년 5월 16일
Hi Andrew,
Assuming you are using the SimBiology app, you can do this by right-clicking on the simulation plot and selecting 'Export Data':
screenshot1.png
Then you can select to export directly to .xls:
screenshot2.png
If you want to export the data from a SimData object in the MATLAB workspace, you could use code along the lines of:
% make datanames suitable for use as variable names (replace all spaces by underscores)
datanames = tobj.DataNames;
datanames = replace(datanames,' ','_');
%create table from data array
dataTable = array2table(tobj.Data,'VariableNames',datanames);
% create table from time array
timeTable = array2table(tobj.Time,'VariableNames',{'Time'});
% concatenate time and data tables
exportTable = [timeTable dataTable];
% export to .xls file
writetable(exportTable,'exportData.xls')
Let me know how you get on.
  댓글 수: 3
Sietse Braakman
Sietse Braakman 2019년 5월 16일
Thanks for letting me know. Do you mean the third option in the right-click drop down ("Export Data...") or the third option to export to Excel in the dialog box ("Save data to Excel file:")?
Andrew Heitman
Andrew Heitman 2019년 5월 16일
I updated with a screenshot - I mean the the third option in the dialog box

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sietse Braakman
Sietse Braakman 2019년 5월 16일
It looks like you are on Mac OS - the export to Excel uses the function xlswrite, which unfortunately only works on Windows.
So alas, you'll have to use some code to achieve this. You can use/adopt the code I wrote above. Whenever you simulate a model in your SimBiology task editor, the simulation data will be present in the MATLAB workspace and will be called 'tobj'. You should be able to use that code to write the tobj to an excel. Note that this code uses the writetable function, rather than xlswrite.
  댓글 수: 9
Shakir Atoyebi
Shakir Atoyebi 2024년 6월 11일
편집: Shakir Atoyebi 2024년 6월 11일
Hi Fulden,
Thanks for your kind response. It worked! I was able to use the code you shared to export the results into multiple sheets on Excel.
One more thing, how might I modify the code to get the 'time' values exported alongside the other data within the results? Thank you.
Shakir
Fulden Buyukozturk
Fulden Buyukozturk 2024년 6월 27일 22:24
Hi Shakir - I missed your follow up question, sorry. To add time data along with state data, you can do:
A = arrayfun(@(x) array2table([x.Time, x.Data],'VariableNames', ['Time'; x.DataNames]),results,UniformOutput=false);
Fulden

댓글을 달려면 로그인하십시오.

커뮤니티

더 많은 답변 보기:  SimBiology Community

카테고리

Help CenterFile Exchange에서 Scan Parameter Ranges에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by