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 CenterFile Exchange에서 Develop 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