Help with code to convert Simbiology sbproj file into gPKPDSim session file in .mat format
1 次查看(过去 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!