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 回表示 (過去 30 日間)
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.

採用された回答

Kevin Holly
Kevin Holly 2023 年 1 月 30 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by