How to call a function to read some files from a specific folder?
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Mahdi Khademishamami
il 16 Mar 2022
Commentato: Stephen23
il 16 Mar 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 Commenti
Risposta accettata
KSSV
il 16 Mar 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 Commenti
Stephen23
il 16 Mar 2022
It is recommended to use FULLFILE, e.g.:
filename1 = fullfile(thepath,'lineinjection.dpm')
Più risposte (0)
Vedere anche
Categorie
Scopri di più su File Name Construction in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!