Unable to concatenate the table variables 'Var1' and 'Var2', because their types are double and cell. Index in position 1 exceeds array bounds. Index must not exceed 3.
2 views (last 30 days)
Show older comments
that is my result .txt and code MATLAB.
I want to run this code to save 3D to 1D. Please help me. Note : I'm not good at MATLAB.
clc
clear
clear all
del = -0.0005;
dx = del;
node = 1/dx+1;
extension = '.txt'; % 拡張子
numfiles = 60; % 時系列ファイル数
outputstep = 1600; % 時系列データファイルの出力タイムステップ
filetypenum = 6; % 入力データ種類数
for l = 1:numfiles
numfiles;
l
for i = 1:filetypenum
if (i == 1) rootname = 'eps'; % ファイル名に使用する文字列
end
if (i == 2) rootname = 'velo'; % ファイル名に使用する文字列
end
if (i == 3) rootname = 'sat'; % ファイル名に使用する文字列
end
rootname2 = 'all';
data = outputstep*l;
filename = [rootname, num2str(data), extension]; % ファイル名の作成
delimiterIn = ';';
headerlinesIn = 2;
A = importdata(filename,delimiterIn,headerlinesIn);
%A = table2array(readtable('eps1600.txt'));
xrow = A.data(1,:);
yrow = A.data(2,:);
zrow = A.data(3,:);
vrow = A.data(4,:);
x = transpose(xrow);
y = transpose(yrow);
z = transpose(zrow);
v = transpose(vrow);
F = scatteredInterpolant(x,y,z,v);
[xq,yq,zq] = meshgrid([0.001:dx:-0.001],[0.0013:-dx:-0.0013],[0.0005:dx:-0.0005]);
%[xq,yq,zq] = meshgrid(linspace(0.001,-0.001,5),linspace(0.00013,-0.00013,5),linspace(0.0005,-0.0005,5));
if i==1
eps = F(xq,yq,zq);
eps2d=mean(eps,3);
%imagesc(xq(1,:),yq(:,1),eps2d)
%colorbar;
%caxis([0, 1]);
%f=gcf;
%filenamejpg = ['eps3Dto2D.jpg'];
%exportgraphics(f,filenamejpg,'Resolution',300)
isoval = 0.95;
h = patch(isosurface(eps,isoval),...
'FaceColor','blue',...
'EdgeColor','none',...
'AmbientStrength',.2,...
'SpecularStrength',.7,...
'DiffuseStrength',.4);
isonormals(eps,h)
%patch(isocaps(eps,isoval),...
% 'FaceColor','interp',...
% 'EdgeColor','none')
%colormap default
daspect([1,1,1])
axis tight
view(3) %view(-37.5,30)
camlight right
camlight left
%eps2d=squeeze(eps2d(:,:,(node-1)/2));
avgeps = mean(eps2d,1);
avgepsT = transpose(avgeps);
%%%%
%xslice = [0.25,0.5,0.75];
%yslice = [0.0];
%zslice = [-0.25,0.0,0.25];
%h=slice(xq,yq,zq,eps,[],[],zslice);
%set(h,'edgecolor','none');
%%%%
%imagesc(xq(1,:),yq(:,1),eps2d)
%colorbar;
%caxis([0, 1]);
%imagesc(xq(1,:),yq(:,1),avgeps)
end
if i==2
c = F(xq,yq,zq);
c2d=mean(c,3);
%c2d=squeeze(c2d(:,:,(node-1)/2));
avgc = mean(c2d,1);
avgcT = transpose(avgc);
%imagesc(xq(1,:),yq(:,1),avgc)
end
if i==3
kac = F(xq,yq,zq);
kac2d=mean(kac,3);
%kac2d=squeeze(kac2d(:,:,(node-1)/2));
avgkac = mean(kac2d,1);
avgkacT = transpose(avgkac);
%imagesc(xq(1,:),yq(:,1),avgkac)
end
end
end
0 Comments
Answers (1)
Varun
on 31 Aug 2023
Hello!
I unzipped your files and tried to run the provided code on my end. I observed that the error comes on assigning the value of “A.data(4,:)” to “vrow”. I compared the file “eps1600.txt” to other files in the folder such as “velo1600.txt”, “sat1600.txt”, etc and realized that the file “eps1600.txt” lacks the two header lines present in every other file. Example, in the “sat1600.txt” file, we have
Meanwhile, in the file “eps1600.txt” we have
So, fixing the file “eps1600.txt” should resolve the error.
Hope this helps!
Thanks,
Varun
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!