- Numeric datatypes supported by MATLAB: https://www.mathworks.com/help/matlab/numeric-types.html
- "class": https://www.mathworks.com/help/matlab/ref/class.html
'Value' in App Designer must be a scalar of type double. How do I fix the error?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function ButtonPushed(app, event)
[UA, NTU, e, T_w, Q, Q_t, C_min] = Calculate(app);
clc
fprintf("UA = %g W/K\n",UA)
fprintf("NTU = %g\n",NTU)
fprintf("e = %g\n",e)
fprintf("냉각수 수렴 온도 = %g 'C\n",T_w)
fprintf("라디에이터 방열량 = %g kW\n",Q)
fprintf("C_min = %.2f\n", C_min)
%% 결과 도출 %%
app.Target_UA.Value = UA;
app.NoTU.Value = NTU;
app.Effective.Value = e;
app.Final_T_water.Value = T_w;
app.Q_Radiator.Value = Q;
if Q >= Q_t
app.Lamp.Color = [0.00,0.00,1.00];
app.Label_13.Text = "냉각";
else
app.Lamp.Color = [1.00,0.00,0.00];
app.Label_13.Text = "과열";
end
end
I wrote the ButtonPushed function code above in App Designer. As a result of checking the five clearly calculated variables using the 'fprintf' function, each appears as a real number scalar like
"UA = 8573.74 W/K
NTU = 14.4686
e = 0.999613
냉각수 수렴 온도 = 57.7925 'C
라디에이터 방열량 = 58.9937 kW
C_min = 0.59",
but I don't know why it keeps saying 'Value' in
"app.Target_UA.Value = UA;
app.NoTU.Value = NTU;
app.Effective.Value = e;
app.Final_T_water.Value = T_w;
app.Q_Radiator.Value = Q;"
must be a double scalar and it doesn't work. Is it a bug in the program itself?
0 commentaires
Réponses (1)
Ayush Modi
le 14 Jan 2024
Modifié(e) : Ayush Modi
le 14 Jan 2024
Hi,
As per my understanding, you are returning the values from calculate function. It is not sufficient to print the values of the variable to check the datatype. "fprintf" function will display the values but not the type and there are multiple numerical datatypes in MATLAB.
You can explicitly convert the value to "double" datatype before assigning them to the 'Value' property. Here is an example to demonstrate how you can achieve this:
app.Target_UA.Value = double(UA);
Also, you can check the class of a variable using "class" function. Here is an example:
classname = class(UA)
Please refer to the following MathWorks documentation for more information on:
I hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Analog Filters dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!