MATLAB Answers

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

1 view (last 30 days)
Zeyad Elsayed
Zeyad Elsayed on 14 Aug 2019
Edited: Zeyad Elsayed on 14 Aug 2019
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)/...
W1_tot_jr = sqrt(((-n1*(R1_jr*omega1_jr*...
A = omega1_j*(((-n1*(R1_jr*L1_jr*(L1_jr/c1_jr)^2)*...
B = (((c1_jr*e1_jr*W1_tot_jr*sin(phi1_jr))/2)+(2*pi*n1*(R1_jr^3)*...
Error = abs(A-B);
if Error < 1E-3, break, 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!

Answers (0)




Community Treasure Hunt

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

Start Hunting!

Translated by