How to call a function to read some files from a specific folder?
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mahdi Khademishamami
am 16 Mär. 2022
Kommentiert: Stephen23
am 16 Mär. 2022
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!
0 Kommentare
Akzeptierte Antwort
KSSV
am 16 Mär. 2022
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 Kommentare
Stephen23
am 16 Mär. 2022
It is recommended to use FULLFILE, e.g.:
filename1 = fullfile(thepath,'lineinjection.dpm')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu File Name Construction finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!