Why was my code working then error message appears?

4 visualizzazioni (ultimi 30 giorni)
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 Commenti
Guillaume
Guillaume il 3 Ago 2018
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.
Ernest Adisi
Ernest Adisi il 3 Ago 2018
Error using contourf (line 57) Z must be at least a 2x2 matrix.
Error in PIV_Post_Process (line 45) contourf(X,Y,Vq);
>>

Accedi per commentare.

Risposte (1)

Ashutosh Sharma
Ashutosh Sharma il 3 Ago 2018
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.

Categorie

Scopri di più su Contour Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by