フィルターのクリア

How to call a function to read some files from a specific folder?

10 ビュー (過去 30 日間)
Mahdi Khademishamami
Mahdi Khademishamami 2022 年 3 月 16 日
コメント済み: Stephen23 2022 年 3 月 16 日
Hi everyone,
I have two files containing some data, and I want to define a function that can be called to read the contents. Suppse the folder containing the data is:
cd 'D:\...\multiparts test2'
filename="lineinjection.dpm"
[x0,y0,z0,u0,v0,w0,diameter0,t0,parcelmass,mass,ninparcel,time,flowtime,inj]=sampleread(filename)
filename1="lineinjection2.dpm"
[x,y,z,u,v,w,diameter,t,parcelmass,mass,ninparcel,time,flowtime,inj]=sampleread(filename1)
How should I give the correct file address to the function in the input format from script?
Thank you for any lead!

採用された回答

KSSV
KSSV 2022 年 3 月 16 日
thepath = 'D:\...\multiparts test2' ;
filename1 = [thepath,filesep,'lineinjection.dpm'] ;
filename2 = [thepath,filesep,'lineinjection2.dpm'] ;
% Now call the function to read the contents of files
[x1,y1,z1,u1,v1,w1,diameter1,t1,parcelmass1,mass1,ninparcel1,time1,flowtime1,inj1]=sampleread(filename1) ;
[x2,y2,z2,u2,v2,w2,diameter2,t2,parcelmass2,mass2,ninparcel2,time2,flowtime2,inj2]=sampleread(filename2) ;
  2 件のコメント
Mahdi Khademishamami
Mahdi Khademishamami 2022 年 3 月 16 日
Thank you so much!
Stephen23
Stephen23 2022 年 3 月 16 日
It is recommended to use FULLFILE, e.g.:
filename1 = fullfile(thepath,'lineinjection.dpm')

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFile Name Construction についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by