Hi, I am coding something in the app designer. I have tried it a test script and it worked fine but when coding into the app, there seems to be an error . Please Help !

1 vue (au cours des 30 derniers jours)
I have tested the following code in the script editor and it works fine. But as soon as I copy the code into the app designer, it failes not sure why.
Below is the code I used in the test script.
clc;
%introducing properties
Ta = 100;
Tb = 0;
dmax = 20; %max amount of the barrier could be i.e. size of the entire plastic
Height = 40;
width = 10;
k = 0.257;
iceThickness = 0.01;
A = (Height * width);
deltaT = Ta - Tb;
for d=1:dmax
Q(d) = (k * A * deltaT)/d;
end
T = transpose (Q);
j=0;
for i=1:dmax
j=j+1;
X(j,:) = [i];
end
volume = A*iceThickness;
iceMass = 0.917*volume;
iceMelt = 334*iceMass;
plot(X, T,'red','lineWidth',2); hold on;
yline(iceMelt,'blue','lineWidth',2); hold on;
I have attached the app code and it fails but I dont understand why the code keeps falling over. Can some please help explain what the issue is?
Thank you in advance.

Réponse acceptée

Kevin Holly
Kevin Holly le 30 Jan 2023
You were not defining your property variables unless the editfields were changed. I added a startup function that pulls the values from the editfield. See app attached.
Note, you could just reference the editfield values and skip the need for the property variables. For instance, you could use app.ThermalConductivitykEditField.Value instead of app.k within your plot callback function.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by