Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to save the values that meet the stated condition and continue until loop ends?

1 visualización (últimos 30 días)
Hello everyone,
I got this code:
% Assumed:
omega1_r = 1.5E3;
% C
% R
n1 = 6.4E-3; % Dynamic viscosity (Pa.s)
R1_rb = 8E-3; % Bore radius (m)
L1_rb = 9E-3; % Length (m)
c1_rb = 74E-6; % Radial clearance (m)
U = 1;
% J
R1_jr = 5.534E-3; % Bore radius (m)
L1_jr = 6.5E-3; % Length (m)
c1_jr = 34E-6; % Radial clearance (m)
omega = 10E3;
omega1_j = omega; % Rotational Speed of the Shaft (rad/s)
omega1_jr = omega1_j - omega1_r;
% E
e1_jr = 0.3;
% Iterations
for e1_rb = 0.1:1E-8:1
phi1_rb = atan(pi*((1-(e1_rb^2))^0.5)/(4*e1_rb));
phi1_jr = atan(pi*((1-(e1_jr^2))^0.5)/(4*e1_jr));
W1_tot_rb = sqrt(((-n1*(R1_rb*omega1_r*(L1_rb/c1_rb)^2)*((e1_rb^2)/...
((1-(e1_rb^2))^2)))^2)+(((pi*n1/4)*(R1_rb*omega1_r*(L1_rb/c1_rb)^2)*...
((e1_rb^2)/((1-(e1_rb^2))^1.5)))^2));
W1_tot_jr = sqrt(((-n1*(R1_jr*omega1_jr*...
(L1_jr/c1_jr)^2)*((e1_jr^2)/((1-(e1_jr^2))^2)))^2)+(((pi*n1/4)*...
(R1_jr*omega1_jr*(L1_jr/c1_jr)^2)*((e1_jr^2)/((1-(e1_jr^2))^1.5)))^2));
A = omega1_j*(((-n1*(R1_jr*L1_jr*(L1_jr/c1_jr)^2)*...
((e1_jr^2)/((1-(e1_jr^2))^2)))^2)+(((pi*n1/4)*(R1_jr*L1_jr*(L1_jr/c1_jr)^2)*...
((e1_jr^2)/((1-(e1_jr^2))^1.5)))^2))/((((-n1*(R1_rb*L1_rb*(L1_rb/c1_rb)^2)*...
((e1_rb^2)/((1-(e1_rb^2))^2)))^2)+(((pi*n1/4)*(R1_rb*L1_rb*(L1_rb/c1_rb)^2)*...
((e1_rb^2)/((1-(e1_rb^2))^1.5)))^2))-(((-n1*(R1_jr*L1_jr*(L1_jr/c1_jr)^2)*...
((e1_jr^2)/((1-(e1_jr^2))^2)))^2)+(((pi*n1/4)*(R1_jr*L1_jr*(L1_jr/c1_jr)^2)*...
((e1_jr^2)/((1-(e1_jr^2))^1.5)))^2)));
B = (((c1_jr*e1_jr*W1_tot_jr*sin(phi1_jr))/2)+(2*pi*n1*(R1_jr^3)*...
omega1_j*L1_jr/(c1_jr*sqrt(1-(e1_jr^2))))-((c1_rb*e1_rb*W1_tot_rb*...
sin(phi1_rb))/2))/((2*pi*n1*(R1_rb^3)*L1_rb/(c1_rb*sqrt(1-(e1_rb^2))))...
+(2*pi*n1*(R1_jr^3)*L1_jr/(c1_jr*sqrt(1-(e1_jr^2)))));
Error = abs(A-B);
if Error < 1E-3, break, end
end
The code works fine but it stops when the first value of "e1_rb" meets the condition "Error < 1E-3". How can I save all the values that meet the conditions? So eventhough the condition is met I want the loops to continue until the range of "e1_rb" ends.
Thanks everyone!

Respuestas (0)

La pregunta está cerrada.

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by