关于我想要的内容摘要:如果我将文件名作为函数的参数,如何将该文件名包含在路径位置中,使得路径位置中的文件名是一个用户输入的。如果你不明白我在说什么,然后阅读下面的解释:如何在Matlab中将通用文件名称作为函数参数包含在路径位置中?
二次说明:
我提出这要求呼叫被叫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')
太快了!谢谢 :) – Pupil 2010-10-06 01:14:43