Why was my code working then error message appears?
2 次查看(过去 30 天)
显示 更早的评论
ive been using this code to run perfectly, but all of a sudden I get an error in the plotting that i dont understand can anyone let me know what please?
files=dir('*.dat');
%%Preallocate some cells
x=cell(1,numel(files));
y=cell(1,numel(files));
u=cell(1,numel(files));
v=cell(1,numel(files));
for i=1:numel(files) filename=files(i).name;
delimiterIn= ' ';
headerlinesIn = 3;
A= importdata(filename,delimiterIn,headerlinesIn);
c = 214;%columns i
r = 134;%rows j
dt= 0.0005; pix_c= 0.2643e-3;% m/pix
%%Save results
x{i}=reshape(A.data(:,1),r,c)*pix_c; % m
y{i}=reshape(A.data(:,2),r,c)*pix_c; %m
u{i}=(((reshape(A.data(:,3),r,c))*pix_c)/dt); %m/s
v{i}=(((reshape(A.data(:,4),r,c))*pix_c)/dt); %m/s
end
%% Mean Velcity matrices
V = cat(3, v{:}); V_m=mean(V,3);
U = cat(3, u{:});
U_m=mean(U,3);
%% Mean Velocities plot
%%%% V-mean%%
[X,Y]=meshgrid(0:max(x{1}(:)),0:max(y{1}(:)));
Vq=griddata(x{1}(:),y{1}(:),V_m(:),X,Y);
f1=figure;
contourf(X,Y,Vq);
xlabel({'x(m)'})
ylabel({'y(m)'})
title('V-mean velcity profile')
hcb=colorbar;
title(hcb,'Velocity [m/s]')
%%%% U-mean%%
[X,Y]=meshgrid(0:2:max(x{1}(:)),0:2:max(y{1}(:)));
Uq=griddata(x{1}(:),y{1}(:),U_m(:),X,Y);
f2=figure;
contourf(X,Y,Uq)
xlabel({'x(m)'})
ylabel({'y(m)'})
title('U-mean velcity profile')
hcb=colorbar;
title(hcb,'Velocity [m/s]')
2 个评论
Guillaume
2018-8-3
I get an error
Giving us the full text of the error would be the first requirement to getting an answer. Copy/paste everything in red.
回答(1 个)
Ashutosh Sharma
2018-8-3
First you have to put all the values of the data/variables(filename,delimiterIn,headerlinesIn) then run the code may be you can run the code after that.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Contour Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!