Undefined function 'mtimes' for input arguments of type 'matlab.ui​.control.N​umericEdit​Field' error

52 Ansichten (letzte 30 Tage)
oil_SAE = app.oil_type.Value;
Temp_in = app.Inlet_Temperature.Value;
d = app.Shaft_diameter.Value;
r = app.Shaft_radius.Value;
D = app.Bushing_diameter.Value;
N = app.Shaft_speed;
W = app.Radial_load.Value;
L = app.Bearing_length.Value;
c = (D-d)/2;
C_ratio = r/c;
P = W/(2*r*L);
Slenderness = L/d;
Sommerfeld_No_Inf = xlsread ('MFT','Temperature Rise Variable','A4:A17');
Temp_rise_inf = xlsread ('MFT','Temperature Rise Variable','E4:E17');
Temperature = xlsread ('MFT','viscosity-temperature chart','A4:A30');
if oil_SAE == 10
y = xlsread ('MFT','viscosity-temperature chart','B4:B30');
elseif oil_SAE == 20
y = xlsread ('MFT','viscosity-temperature chart','C4:C30');
elseif oil_SAE == 30
y = xlsread ('MFT','viscosity-temperature chart','D4:D30');
elseif oil_SAE == 40
y = xlsread ('MFT','viscosity-temperature chart','E4:E30');
elseif oil_SAE == 50
y = xlsread ('MFT','viscosity-temperature chart','F4:F30');
elseif oil_SAE == 60
y = xlsread ('MFT','viscosity-temperature chart','G4:G30');
elseif oil_SAE == 70
y = xlsread ('MFT','viscosity-temperature chart','H4:H30');
end
%-------------------------------------------------------------------------%
% Calculation to find average temperature and viscosity %
Tf = Temp_in + 3;
app.V.Value = interp1 (Temperature,y,Tf);
app.S.Value = (C_ratio)^2*((app.V*N)/P); error: Undefined function 'mtimes' for input arguments of type 'matlab.ui.control.NumericEditField'.
if Slenderness == 1
app.delta_T.Value = (0.349109 + (6.00940*app.S)+(0.047467*(app.S^2)))*(P*(10^-6))/0.120; % Temperature Rise(°C) at l/d=1
elseif Slenderness == 1/2
app.delta_T.Value = (0.394552 + (6.392527*app.S)-(0.036013*(app.S^2)))*(P*(10^-6))/0.120; % Temperature Rise(°C) at l/d=1/2
elseif Slenderness == 1/4
app.delta_T.Value = 0.933828 + (6.437512*app.S)- (0.011048*(app.S^2))*(P*(10^-6))/0.120; % Temperature Rise(°C) at l/d=1/4
else
app.delta_T.Value = (interp1 (Sommerfeld_No_Inf,Temp_rise_inf,app.S))*(P*(10^-6))/0.120; % Temperature Rise(°C) at l/d=Infinity
end
app.T_average.Value = Temp_in + (app.delta_T.Value/2);
** I got the error while running the app designer. These codes were written in callback function. Can somebody help me on how to fix this error?
  2 Kommentare
Jan
Jan am 26 Jul. 2019
Please use the buttons on top of the field for editing the message to format the code as code to improve the readability. Thanks.
By the way, you mix the code for the GUI handling and the computations. This will impede the maintenance of the code. If you separate the GUI part and the actual computations, it will be much easier to modify the GUI or the calculations, or use the function for the calculations in another code. Example:
% Inside the GUI code:
[V, S, Delta, T_avg] = YourCalculations(Temperature, C_ratio, y, Tf, ...
N, P, Slenderness)
app.V.Value = V;
app.S.Value = S;
... and so on
% And the calculations:
function [V, S, Delta, T_avg] = YourCalculations(Temperature, C_ratio, y, Tf, ...
N, P, Slenderness)
V = interp1(Temperature,y,Tf);
S = (C_ratio)^2 * V * N ) / P);
if Slenderness == 1
delta_T = (0.349109 + (6.00940*S)+(0.047467*(S^2)))*(P*1e-6)/0.120;
... and so on
end
end

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Dennis
Dennis am 26 Jul. 2019
app.S.Value = (C_ratio)^2*((app.V.Value*N)/P);
You forgot the '.Value', the error message tells you that you can not multiply the handle of your edit field.

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by