getting errors while trying to plot
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Cris LaPierre
el 29 de Mzo. de 2023
Attach your text files to your post using the paperclip icon, and then we can say for certain.
Respuestas (1)
Mathieu NOE
el 29 de Mzo. de 2023
Movida: Fangjun Jiang
el 29 de Mzo. de 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 comentario
Mathieu NOE
el 29 de Mzo. de 2023
Movida: Fangjun Jiang
el 29 de Mzo. de 2023
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 ?
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!