Borrar filtros
Borrar filtros

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

10 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

KSSV
KSSV el 16 de Mzo. de 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 comentarios
Stephen23
Stephen23 el 16 de Mzo. de 2022
It is recommended to use FULLFILE, e.g.:
filename1 = fullfile(thepath,'lineinjection.dpm')

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre File Name Construction en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by