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!