【发布时间】:2010-10-06 00:58:48
【问题描述】:
我想要的内容的简要总结:如果我将文件名作为函数的参数,我如何在路径位置中包含该文件名,以便路径中的文件名location 是用户输入的位置。如果您不明白我在说什么,请阅读下面的解释:
次要解释:
我正在制作一个需要调用 CMG 软件的通用功能。该软件需要一个.dat 文件,我将其名称作为函数中的参数,参数中的通用名称为ReservoirModel_CMGBuilder。正如您在下面的部分代码中看到的那样,这个ReservoirModel_CMGBuilder 文件保存在我输入的路径位置的文件夹中。但是问题是因为文件名是用引号引起来的,所以它不能识别代码中的文件名。我想要的是从用户那里获取 CMG 所需的 .dat 文件名的名称并将其存储在名称 ReservoirModel_CMGBuilder 中,然后在路径位置中使用该名称来获取该文件。
同样,我想为Reportq_rwd 和Reportq_rwo 做这件事。我该怎么做?
function [q_yearly,Swav_yearly]=q_from_CMG_general(nModel,nCell,T,ReservoirModel_CMGBuilder,poro_models_gslib_file,perm_models_gslib_file,Reportq)
ReservoirModel_CMGBuilder=[ReservoirModel_CMGBuilder '.dat']; % string concatenation
Reportq_rwd=[Reportq '.rwd'];
Reportq_rwo=[Reportq '.rwo'];
poro_models=gslib_file_to_matlab_var(nModel,nCell,poro_models_gslib_file);
perm_models=gslib_file_to_matlab_var(nModel,nCell,perm_models_gslib_file);
%% loop to run all nModel
for model_no=1:nModel
%% Writing the porosity and permeability model one at a time in .inc file, which will be read and will work as input to porosity and permeability models in CMG
dlmwrite('poro_model.inc',poro_models(:,model_no),'delimiter','\n');
dlmwrite('perm_model.inc',perm_models(:,model_no),'delimiter','\n');
%% Prior to driling an exploratory well or acquiring a seismic with just 5 producing wells
%# Calls CMG
system('mx200810.exe -f "C:\Documents and Settings\HSingh2\Desktop\Work\Model - SGEMS, CMG and MATLAB\ReservoirModel_CMGBuilder"') % Calls CMG
%# Calls parameter report file and generates output file
system('report.exe /f Reportq_rwd /o Reportq_rwo')
【问题讨论】:
标签: matlab function path location