Borrar filtros
Borrar filtros

Error: "filename" must be a string scalar or character vector.

68 visualizaciones (últimos 30 días)
Jamie Al
Jamie Al el 26 de Oct. de 2022
Editada: VBBV el 5 de Nov. de 2022
I am trying to sort of creat an animation of a bunch of text files. The thing is, these text files are techically 3D matrices collapsed as 2D matrix and then I am reshaping them back to 3D to plot.
The code:
upperDir = 'C:\Users\J\Desktop\Folder\';
subDir = {'DataFile\'};
Frame = 161; %number of text files
Nx = 64;
Ny =64;
Nz = 64;
Lx =128;
Ly = 128;
Lz = 128;
x = (0:Nx-1)/Nx*2*pi;
y = (0:Ny-1)/Ny*2*pi;
z = (0:Nz-1)/Nz*2*pi;
dx = Lx/Nx;
dy = Ly/Ny;
dz = Lz/Nz;
[X,Y,Z] = meshgrid(x,y,z);
for i = 1:Frame
%Test=reshape(readmatrix('Test161.txt'),64,64,64);
Test = reshape(readmatrix([upperDir subDir 'n' num2str(i) '.txt']),64,64,64); %error here
figure
isosurface(X,Y,Z,Test);
shading flat;
grid on;
xlabel('x(m)'); ylabel('y(m)'); zlabel('z(m)');
end
The error:
Error using readmatrix (line 157)
"filename" must be a string scalar or character vector.
Error in PlasmaCloud3DFourier (line 351)
Test = reshape(readmatrix([upperDir subDir 'n' num2str(i) '.txt']),64,64,64);

Respuestas (2)

KSSV
KSSV el 26 de Oct. de 2022
Change this line
[upperDir subDir 'n' num2str(i) '.txt']
to
[upperDir,filesep,subDir,filesep,'n',num2str(i),'.txt']
Also have a look on dir. Here you can extract the required text files and make your required path using fullfile
  1 comentario
Jamie Al
Jamie Al el 26 de Oct. de 2022
Editada: Jamie Al el 26 de Oct. de 2022
Sorry, what is filesep here?. Unfortunately, I am getting the same error.

Iniciar sesión para comentar.


VBBV
VBBV el 5 de Nov. de 2022
subDir = 'DataFile\';
Change this line as above.

Categorías

Más información sobre Dialog Boxes 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