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

10 次查看(过去 30 天)
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) ;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 File Name Construction 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by