Borrar filtros
Borrar filtros

txt file assignment value to variables

1 visualización (últimos 30 días)
tony kevine
tony kevine el 8 de Mayo de 2015
Respondida: Walter Roberson el 8 de Mayo de 2015
The file named "resol.INP". Actually it is txt type.
the content is
%%---------------
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
%%---------------
I want to assignment above to those variables ,but it does't work. Can anyone help me.
%%---------------
fid = fopen('resol.INP')
tline = fgetl(fid)
for iresol=1:8
tmp100(1,iresol)= fgetl(fid);
end
[nel_x,nel_y,Frequency_or_Deflection,node,dof,fs,fp,fe]=deal(tmp100(1,1),tmp100(1,2),tmp100(1,3),tmp100(1,4),tmp100(1,5),tmp100(1,6),tmp100(1,7),tmp100(1,8));

Respuestas (1)

Walter Roberson
Walter Roberson el 8 de Mayo de 2015
fgetl() is for retrieving a complete line from a file as text. It outputs a string. You probably want fscanf()

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by