getting errors while trying to plot

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

Fangjun Jiang
Fangjun Jiang 2023년 3월 29일
load() is used for .mat file. For .txt file, you might be able to use readmatrix()
Cesar Cardenas
Cesar Cardenas 2023년 3월 29일
Right, how do I have to modify the code? Not sure about it. Thanks
Cesar Cardenas
Cesar Cardenas 2023년 3월 29일
Basically, what I am trying to do is plot u vs y, and u/Ue vs y/theta every 0.1 m on one plot. Not sure how to pause the code every 0.1 x steps (start at 0.2, pause at 0.3, etc) so that I can get the u, y, theta, and Ue at those points. Any help will be appreciated. Thanks
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일

0 개 추천

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 ?

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

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2023년 3월 29일

편집:

2023년 3월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by