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 Comments

load() is used for .mat file. For .txt file, you might be able to use readmatrix()
Right, how do I have to modify the code? Not sure about it. Thanks
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
Attach your text files to your post using the paperclip icon, and then we can say for certain.

Sign in to comment.

Answers (1)

Mathieu NOE
Mathieu NOE on 29 Mar 2023
Moved: Fangjun Jiang on 29 Mar 2023
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 Comment

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 ?

Sign in to comment.

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Asked:

on 29 Mar 2023

Edited:

on 30 Mar 2023

Community Treasure Hunt

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

Start Hunting!