check out a matlab code method
Ältere Kommentare anzeigen
Hello everyone, I'm deeply sorry to ask this question, because i could'nt resolve it . I'm using R2024a matlab version, and I wanna know how to check a matlab code i mean ( array, matrix,...) . In this part, I would know how to get those errors messages?
if Bearing_Type == 7 % fluid film bearings - based on short width bearing theory
if ncol_bearing < 7, disp('>>>> Error - too few columns in bearing definition matrix for bearing type 7'), end
if Rotor_Spd == 0, disp('>>>> Error - bearing type 7 - fluid bearing model undefined at zero speed'), end
F = Bearing_Def(i,3); % static load (N) colonne 3,The static bearing's force needs to be calculated.
D = Bearing_Def(i,4); % bearing diameter (m) colonne 4
L = Bearing_Def(i,5); % bearing length (m) colonne 5
c = Bearing_Def(i,6); % bearing radial clearance (m) colonne 6
eta = Bearing_Def(i,7); % oil viscosity (Ns/m^2) colonne 7
model.bearing = [7 1 Bearing1_diam Bearing1_clear Bearing1_wid Lubricating_oil_number eta; ...
7 12 Bearing2_diam Bearing2_clear Bearing2_wid Lubricating_oil_number eta];
1 Kommentar
Walter Roberson
am 15 Nov. 2025
If the conditions such as ncol_bearing<7 is met, then you emit an error message, and continue on in the code, including the assignment to model.bearing. I would suggest that if the error messages are omitted, that you want to skip the assignments. Consider using an if / elseif / else structure, or consider using assert
Akzeptierte Antwort
Weitere Antworten (2)
Would be more helpful to see more of the function context, but a couple of recommendations
Firstly, for the diagnostics, parameter validation portion, look at the <Arguments Definitions> section and the <arguments> block.
Secondly it would make using the function and argument list far simpler it you were to use a struct or object definition for the bearings and then an array of those rather than having so many individually-named like variables. Using sequentially numbered variable names such as you have is generally a sign of not using the power of MATLA vector operations which is the strong point of the language.
TYPES={7,7};
DIAMS={diam1,diam2};
CLEAR={clear1. clear2};
WIDTH={wid1, wid2};
OIL=Lubricating_oil_number;
ETA=eta;
Bearings=struct('Type',TYPES,'Diam',DIAMS,'Clearance',CLEARS,'Width',WIDTH,'LubeOil',Oil,'Eta',ETA);
Then you can just pass the Bearings struct array. with all the needed informtion defining each bearing and then what other specific arguments individually.
Amira
am 26 Nov. 2025
0 Stimmen
Kategorien
Mehr zu Fluid Dynamics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!