필터 지우기
필터 지우기

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

조회 수: 68 (최근 30일)
Jamie Al
Jamie Al 2022년 10월 26일
편집: VBBV 2022년 11월 5일
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);

답변 (2개)

KSSV
KSSV 2022년 10월 26일
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
Jamie Al
Jamie Al 2022년 10월 26일
편집: Jamie Al 2022년 10월 26일
Sorry, what is filesep here?. Unfortunately, I am getting the same error.

댓글을 달려면 로그인하십시오.


VBBV
VBBV 2022년 11월 5일
subDir = 'DataFile\';
Change this line as above.
  댓글 수: 1
VBBV
VBBV 2022년 11월 5일
편집: VBBV 2022년 11월 5일
It seems you are using cell character

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by