フィルターのクリア

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 Center および File ExchangeDialog Boxes についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by