Effacer les filtres
Effacer les filtres

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

68 vues (au cours des 30 derniers jours)
Jamie Al
Jamie Al le 26 Oct 2022
Modifié(e) : VBBV le 5 Nov 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);

Réponses (2)

KSSV
KSSV le 26 Oct 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 commentaire
Jamie Al
Jamie Al le 26 Oct 2022
Modifié(e) : Jamie Al le 26 Oct 2022
Sorry, what is filesep here?. Unfortunately, I am getting the same error.

Connectez-vous pour commenter.


VBBV
VBBV le 5 Nov 2022
subDir = 'DataFile\';
Change this line as above.
  1 commentaire
VBBV
VBBV le 5 Nov 2022
Modifié(e) : VBBV le 5 Nov 2022
It seems you are using cell character

Connectez-vous pour commenter.

Catégories

En savoir plus sur Dialog Boxes dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by