Help with code to convert Simbiology sbproj file into gPKPDSim session file in .mat format
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm trying to learn gPKPDSim and it seems my first step is to create a project file in Simbiology that will subsequently be changed into .mat format to load as a session file into gPKPDSim. Dr. Hosseini states in his paper "gPKPDSim: a SimBiology-based GUI application for PKPD modeling in drug development" that a program he provides called "Configuration.m" will make this conversation. I found the code for the "Configuration.m" file but am getting errors, probably due to my lack of knowledge of Matlab.
After I clear the screen, I enter "Analysis = PKPD.Analysis;", which works. I'm next supposed to enter "PathName = fileparts(which(mfilename));" so I enter
PathName = fileparts(which('C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\PPG Swine mean SD.sbproj'));
While no error is created, the variable PathName returns "0×0 empty char array", which I presume means it is empty. This impacts the subsequent code to produce an error. When I enter
exist 'C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\PPG Swine mean SD.sbproj'
I get an answer of 2, so I presume the file is there. I hate to ask such a simple question but what do I have wrong in the syntax?
Thanks
댓글 수: 0
채택된 답변
Arthur Goldsipe
2018년 10월 29일
Ah, I finally figured out what's going on. The function "which" can only be used to locate files that are in the current working directory or on the MATLAB path. So if you "cd" into your gPKPDSim directory (or add it to your MATLAB path) and then run the command, then you should see that PathName is not empty.
However, that's probably not even necessary. If you are hard-coding the path, then you can just replace the line of code with the directory, that is:
PathName = 'C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\';
But I think the intent of the code is that you don't have to replace "mfilename". mfilename is actually a MATLAB function that returns the name of the file that is currently running. So this allows the configuration file to programmatically determine the file path without you having to type it into the file.
Hopefully that solves your problem this time around.
-Arthur
추가 답변 (6개)
Arthur Goldsipe
2018년 10월 26일
See if your problem is fixed by using two slashes when you define PathName. That is, change the line of code to the following:
PathName = fileparts(which('C:\\Users\\langston\\Documents\\Research\\Pharmacokinetics\\gPKPDSim\\PPG Swine mean SD.sbproj'));
The reason you didn't have to do this with exist is because you invoked it as a "command" rather than as a "function". (For more details, you can read this blog post .) You would have to do the same thing if you invoked it this way:
exist('C:\\Users\\langston\\Documents\\Research\\Pharmacokinetics\\gPKPDSim\\PPG Swine mean SD.sbproj');
댓글 수: 0
CLang
2018년 10월 27일
댓글 수: 1
Arthur Goldsipe
2018년 10월 27일
Sorry, I was wrong. I think double backslashes are only needed when calling functions like sprintf or fprintf. I'll take a closer look again later.
CLang
2018년 10월 29일
댓글 수: 1
Arthur Goldsipe
2018년 10월 29일
importModel is a method that's defined in gPKPDSim. Normally, this error indicates is caused by a typo in the file name or path.
Do you get the same error message if you try the following at the MATLAB command prompt?
sbioloadproject('C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\models\PPG Swine
mean SD.sbproj')
I think that's the command that importModel is running, so I would expect it to error to error here, too. If this command also errors, can you confirm that the following also errors?
exist('C:\Users\langston\Documents\Research\Pharmacokinetics\gPKPDSim\models\PPG Swine
mean SD.sbproj')
I thought you wrote earlier that this command returned 2. But then I wouldn't expect sbioloadproject to error. So something doesn't add up.
What version of MATLAB are you using? I'd like to confirm I'm using the same one. It might also be helpful to include the output of the "ver" command.
CLang
2018년 10월 29일
댓글 수: 1
Arthur Goldsipe
2018년 10월 30일
편집: Arthur Goldsipe
2018년 10월 30일
It took me a while to see the difference, but the two paths are not the same. Note that the failing commands contain a "models" subfolder, which is not correct. Try removing the "models" part of the ProjectPath code:
ProjectPath = fullfile(PathName,'PPG Swine mean SD.sbproj');
Iraj Hosseini
2018년 11월 5일
Hi
To learn gPKPDSim, you can also use the SimBiology models and corresponding session files that we have provided as supplements with the paper. For the config file, we have provided a template that you can modify for your SimBiology model and build the session file.
To run a config file, you need to make sure that the appropriate gPKPDSim folders have been added to PATH. To do so, please run the app and close it. This makes sure all the required folders are setup correctly in Matlab PATH. Then run the config file.
Thanks, Iraj
댓글 수: 0
커뮤니티
더 많은 답변 보기: SimBiology Community
참고 항목
카테고리
Help Center 및 File Exchange에서 Biotech and Pharmaceutical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!