Create a matlab code with given charts

d=input('enter a diameter value:'); %journal diameter (m)
l=input('enter a length value:');   %bearing length (m)
r=d/2;                              %radius (m)
c=input('enter a radial clearance:'); % radial clearance (m)
T1=input('assign an inlet temperature:'); %inlet temperature (celcius)
delta_T=input('enter temperature rise value:'); %assumed temperature rise (celcius)
W=input('enter a radial load on journal:');     %radial load on journal (N)
n_s=input('enter journal speed value of shaft:');       %journal speed (rev/sec)
P=W/(l*d);                                        %bearing pressure (N/m^2)
Tavg_vector=[10:10:140];                        %average temperature vector 
abs_vis_vector=[500 190 90 45 28 18 12 9 6.5 5.2 4.2 3.2 2.8 2.6]; % absolute viscosity vector
Tavg=T1+(delta_T/2);                            %average temperature (celcius)
fabs_vis_vector=csapi(Tavg_vector,abs_vis_vector); %cubic spline interpolation 
absolute_viscosity_value=fnval(fabs_vis_vector,Tavg); %absolute viscosity value mPa.s
absolute_viscosity_value=absolute_viscosity_value*10^-3; %absolute viscosity value Pa.s
Sc=((absolute_viscosity_value*n_s)/P)*(r/c)^2;           %sommerfeld number
%performance parameters for corresponding l/d ratio
if l/d==1
    % for l/d=1 performance parameters
    S_1=[0.0188 0.0446 0.121 0.264 0.631 1.33 ];
    % the corresponding vector for the minimum film thickness variable,h0/c
    hoc_1=[0.1 0.2 0.4 0.6 0.8 0.9 ];
    % the corresponding vector for the coefficient of friction variable, Rf /c
    Rfc_1=[1.05 1.70 3.2 5.79 12.8 26.4];
    % the corresponding vector for the volumetric oil-flow rate, Q/ (RcnL)
    Qc_1=[4.74 4.62 4.33 3.99 3.59 3.37];
    % the corresponding vector for side leakage flow/total flow, Qs/Q
    Qsc_1=[0.919 0.842 0.680 0.497 0.280 0.150]; 
elseif l/d==0.5
    % for l/d=0.5 performance parameters
    S_2=[0.0313 0.0923 0.319 0.779 2.03 4.31];
    % the corresponding vector for the minimum film thickness variable,h0/c
    hoc_2=[0.1 0.2 0.4 0.6 0.8 0.9];
     % the corresponding vector for the coefficient of friction variable, Rf /c
    Rfc_2=[1.60 3.26 8.10 17.0 40.9 85.6];
    % the corresponding vector for the volumetric oil-flow rate, Q/ (RcnL)
    Qc_2=[5.69 5.41 4.85 4.29 3.72 3.43];
    % the corresponding vector for side leakage flow/total flow, Qs/Q
    Qsc_2=[0.939 0.874 0.730 0.552 0.318 0.173];
elseif l/d==0.25
    % for l/d=0.25 performance parameters
    S_3=[0.0736 0.261 1.07 2.83 7.57 16.2];
    % the corresponding vector for the minimum film thickness variable,h0/c
    hoc_3=[0.1 0.2 0.4 0.6 0.8 0.9];
    % the corresponding vector for the coefficient of friction variable, Rf /c
    Rfc_3=[ 3.50 8.8 26.7 61.1 153.0 322.0];
    % the corresponding vector for the volumetric oil-flow rate, Q/ (RcnL)
    Qc_3=[5.91 5.60 4.99 4.37 3.76 3.45 ];
    % the corresponding vector for side leakage flow/total flow, Qs/Q
    Qsc_3=[0.945 0.884 0.746 0.567 0.330 0.180 ];
elseif l/d==inf 
    % for l/d=inf performance parameters
    S_4=[0.0115 0.021 0.0389 0.0626 0.123 0.240];
    % the corresponding vector for the minimum film thickness variable,h0/c
    hoc_4=[0.1 0.2 0.4 0.6 0.8 0.9];
    % the corresponding vector for the coefficient of friction variable, Rf /c
    Rfc_4=[0.961 1.20 1.52 2.57 4.80];
    % the corresponding vector for the volumetric oil-flow rate, Q/ (RcnL)
    Qc_4=[0.760 1.56 2.26 2.83 3.03];
    % the corresponding vector for side leakage flow/total flow, Qs/Q
    Qsc_4=[0 0 0 0 0 0 0 0 0];
end
if l/d==1
% To interpolate the data, the MATLAB function csapi(X,Y) is used:
fhoc_1 = csapi( S_1, hoc_1 );
ffc_1 = csapi( S_1, Rfc_1);
fQR_1 = csapi( S_1, Qc_1);
fQs_1 = csapi( S_1, Qsc_1);
% The values of the interpolated data functions at Sc are calculated with:
hc = fnval(fhoc_1, Sc); % ho/c 
fc = fnval(ffc_1, Sc);  %(r/c)f
Qc = fnval(fQR_1, Sc);  % Q/(r c n L)
Qsc= fnval(fQs_1, Sc);  % Qs/Q 
elseif l/d==0.5
% To interpolate the data, the MATLAB function csapi(X,Y) is used:
fhoc_2 = csapi( S_2, hoc_2);
ffc_2 = csapi( S_2, Rfc_2);
fQR_2 = csapi( S_2, Qc_2);
fQs_2 = csapi( S_2, Qsc_2);
% The values of the interpolated data functions at Sc are calculated with:
hc = fnval(fhoc_2, Sc); % ho/c
fc = fnval(ffc_2, Sc);  %(r/c)f
Qc = fnval(fQR_2, Sc);  % Q/(r c n L)
Qsc= fnval(fQs_2, Sc);  % Qs/Q
elseif l/d==0.25
% To interpolate the data, the MATLAB function csapi(X,Y) is used:
fhoc_3= csapi( S_3, hoc_3 ); 
ffc_3= csapi( S_3, Rfc_3 );  
fQR_3= csapi( S_3, Qc_3 );   
fQs_3= csapi( S_3, Qsc_3 );  
% The values of the interpolated data functions at Sc are calculated with:
hc = fnval(fhoc_3, Sc);  % ho/c
fc = fnval(ffc_3, Sc);   %(r/c)f
Qc = fnval(fQR_3, Sc);   % Q/(r c n L)
Qsc= fnval(fQs_3, Sc);   % Qs/Q
else l/d==inf
% To interpolate the data, the MATLAB function csapi(X,Y) is used:
fhoc_4 = csapi( S_4, hoc_4 );
ffc_4 = csapi( S_4, Rfc_4 );
fQR_4 = csapi( S_4, Qc_4 );
fQs_4= csapi( S_4, Qsc_4 );
% The values of the interpolated data functions at Sc are calculated with:
hc = fnval(fhoc_4, Sc);  % ho/c
fc = fnval(ffc_4, Sc);   %(r/c)f
Qc = fnval(fQR_4, Sc);   % Q/(r c n L)
Qsc= fnval(fQs_4, Sc);   % Qs/Q
end

4 types of l/d ratio is given on the chart as it seen. but when we write a l/d ratio which is not given on the chart we use interpolation to found it. for example if ı want to find l/d=0.60 how can ı write ıts matlab code and calculate it?

2 posts were merged into an existing topic: Create a matlab code with given chart

Please do not create duplicate topics for the same challenge/project question(s). This duplicate topic has been unlisted.

Thank you.