getting errors while trying to plot

조회 수: 1 (최근 30일)
Cesar Cardenas
Cesar Cardenas 2023년 3월 29일
편집: Cesar Cardenas 2023년 3월 30일
I'm trying to plot this but I'm getting errors. Not sure how to fix them. Any help will be greatly appreciated. Thanks much.
% Toggle display for troubleshooting
% disp(['Calculating Streamwise Position ' ...
% num2str(LCVx) ' of ' num2str(Nx) ' (x = ' ...
% num2str(x(LCVx)) ' m)'])
% Solve for u at the next x location
% ENTER CODE HERE %
n=LCVx-1;
u_ns(1)=0;
u_ns(M)=Ue(n+1);
for mi =2:M-1
Q=nu*delta_x/u(mi)/delta_y^2;
P=1/2*delta_x/delta_y*v(mi)/u(mi);
u_ns(mi) = u(mi)+Ue(n)/u(mi)*(Ue(n+1)-Ue(n))+...
Q*(u(mi+1)-2*u(mi)+u(mi-1))-...
P*(u(mi+1)-u(mi-1));
end
% Solve for v at the next x location using the continuity equation
% ENTER CODE HERE %
v_ns(1)=0;
for mi =2:M
P=1/2*delta_y/delta_x;
v_ns(mi) = v_ns(mi-1)- ...
P*(u_ns(mi)-u(mi)+u_ns(mi-1)-u(mi-1));
end
% Update velocity profiles
u = u_ns;
v = v_ns;
% Calculate momentum thickness
% ENTER CODE HERE %
uf = @(z)interp1(y,u,z);
thetafun = @(z)uf(z).*(1-uf(z));
theta(LCVx) = integral(thetafun,min(y),max(y));
% Calculate skin friction coefficient
% ENTER CODE HERE %
cf(LCVx) =((nu/dy)/Uef (xstart)^2)*(4*u(2)-u(3));
if mod(n,500)==0
figure;subplot(1,2,1);plot(y,u_ns);subplot(1,2,2);plot(y,v_ns);
pause;
end
end uplots = u./Ue; yplots = y./theta; for x = xstart:0.2:xend figure hold on plot(y,u) figure hold on plot(yplots,uplots)
end
  댓글 수: 5
Cris LaPierre
Cris LaPierre 2023년 3월 29일
Attach your text files to your post using the paperclip icon, and then we can say for certain.
Cesar Cardenas
Cesar Cardenas 2023년 3월 29일
Thanks for your reply. Enclosed the txt files.

댓글을 달려면 로그인하십시오.

답변 (1개)

Mathieu NOE
Mathieu NOE 2023년 3월 29일
이동: Fangjun Jiang 2023년 3월 29일
the error message is quite clear
Unable to find file or directory 'negm_profiles.txt'.
this file is not in your directory
double check by typing in your command window
dir *.txt
if you need more help , it's genrally a good thing to share your data files along the code
  댓글 수: 1
Mathieu NOE
Mathieu NOE 2023년 3월 29일
이동: Fangjun Jiang 2023년 3월 29일
your code works fine with the provided txt files.
the next problem is here , here arrays size are not matching
uplots = u./Ue;
yplots = y./theta;
u and y are 300x1 arrays while Ue and theta are 8001x1 arrays
which one is the good size and how will you modify the code accordingly ?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by