Need MATLAB help for assignment

3 visualizaciones (últimos 30 días)
Connor Linden
Connor Linden el 9 de Mzo. de 2021
Comentada: Rik el 10 de Mzo. de 2021
𝐹𝑝(𝑛) 𝐹𝑑 = 16/3 ( 1/𝐶𝐷 ) 1/(𝑏⁄𝐷5) ( 𝑉0/𝑢 )^ 2 ( 1/𝑅 )^ 3 √( 1/𝑅 )^4 − 2 ( 1/𝑅)^ 2 cos 2𝜃 + 1
Fp(n)/Fd = the ratio between radial pressure and bed forces
CD = drag coefficient (assume it is 1.0 for this problem)
V0/u = the ratio between upstream velocity and velocity near the pile (assume this term = 1.0);
R = the radius from the pile (in cylindrical coordinates)
𝜃 = the angle from the pile (in cylindrical coordinates)
Plot contours of the above expression for b/D50 ratios of [0.1, 1.0, 10, 100] for radii up to 5.0 m using a function to perform all computations for this expression. I am aware that we have not formally done contours yet, but we have done surface plotting (in class one day; check your notes). Type help contour to see how the command works. I am testing your ability to learn and apply a new command here.
Present your results using a 2x2 subplotted plotting window. Label your contours using the command ‘clabel’ (type ‘help clabel’ to learn the proper syntax). Be sure to give your plots proper titles and x,y labels.
this is the code i have so far
function F = MidtermGraph(R,theta,bD)
bD = [0.1, 1.0, 10, 100];
R = (1:1.25:5);
c = R;
a = 1/2*bD;
b = abs(sqrt(c.^2 - a.^2));
theta = abs(atan(b./a));
for r = 1:length(R)
for b = 1:length(bD)
F = (16/3).*(1./bD).*(1./R).^3.*abs(sqrt((1./R).^4-2.*(1./R).^2.*cos(2.*theta)+1));
end
end
[F] = MidtermGraph(R,theta,bD);
for b = 1:length(bD)
figure(1)
subplot(2,2,b)
x = R.*cos(theta);
y = R.*sin(theta);
z = F;
[x,y,z] = meshgrid(x,y,z);
[C,h] = contour(R,theta,bD,x,y,z);
clabel(C,h);
grid on
xlabel('b/D50')
ylabel('radii')
title('Radial Pressure vs. Bed Forces')
end
  2 comentarios
Walter Roberson
Walter Roberson el 9 de Mzo. de 2021
Editing away your question is not the way to thank a volunteer for taking the time to analyze your code and describe what is wrong with it and what is needed to do in order to repair it. :(
Rik
Rik el 10 de Mzo. de 2021

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 9 de Mzo. de 2021
for r = 1:length(R)
for b = 1:length(bD)
F = (16/3).*(1./bD).*(1./R).^3.*abs(sqrt((1./R).^4-2.*(1./R).^2.*cos(2.*theta)+1));
end
end
That code is overwriting all of F in every iteration.
Both of your functions have the same name.
Your second function asks to return F but does not calculate F. It also needs the value of F but F is not input or output.
  1 comentario
Walter Roberson
Walter Roberson el 9 de Mzo. de 2021
Most of the time it is best to structure the code into at least two parts. One of the parts is the user interface, asking the user for any relevant inputs, calling the second part to do the calculations, and then either doing the plotting or calling a third part to do the plotting. The second part would be the pure calculation. If you construct a third part, make it pure plotting.

Iniciar sesión para comentar.

Categorías

Más información sobre Vector Fields en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by