Why was my code working then error message appears?

4 ビュー (過去 30 日間)
Ernest Adisi
Ernest Adisi 2018 年 8 月 3 日
コメント済み: Ernest Adisi 2018 年 8 月 3 日
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
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.
Ernest Adisi
Ernest Adisi 2018 年 8 月 3 日
Error using contourf (line 57) Z must be at least a 2x2 matrix.
Error in PIV_Post_Process (line 45) contourf(X,Y,Vq);
>>

サインインしてコメントする。

回答 (1 件)

Ashutosh Sharma
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.

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by