필터 지우기
필터 지우기

Difficulties in Assembling an array from NumericEditFields in app designer

조회 수: 2 (최근 30일)
I need to assemble a 4x1 array from user-submitted data in NumericEditFields button fields.
When I use direct data by a matrix initiated directly my neural network can perform the simulation.
Matrix that works (example)
D1= [150; 22; 10; 5;]
D1=
150
22
10
5
However, if this data is sent by the user and I assemble an array with the following code:
app.D1 = [app.Is; app.Us; app.Vs; app.Es;]
where app.Is.. are the values of the fields entered by the user, the D1 array does not assemble an array and the following error appears.
Error using network/sim (line 248). Inputs is not a matrix or cell array.
I created a "test" button to send me the data of the assembled array and the return is as follows:
value =
4×1 NumericEditField array:
NumericEditField (150)
NumericEditField (22)
NumericEditField (10)
NumericEditField (5)
How do I create an array D1= [150; 22; 10; 5;] what works?
Can someone help me?

채택된 답변

Walter Roberson
Walter Roberson 2022년 8월 9일
app.D1 = [app.Is.Value; app.Us.Value; app.Vs.Value; app.Es.Value];
Or... you could leave app.D1 as it is, and at the time you need the numeric values from it,
D1 = arrayfun(@(F)F.Value, app.D1);
The difference between these two is that the first one fetches the numeric values as of the time the assignment to app.D1 is made, whereas the second records the numeric values as of the time that the assignment to D1 is made (with app.D1 recording the handles to the edit fields.)
  댓글 수: 1
Arlan Pacheco Figueiredo
Arlan Pacheco Figueiredo 2022년 8월 9일
편집: Arlan Pacheco Figueiredo 2022년 8월 9일
Thank you very much Walter, with this code the app worked correctly.
I used "arrayfun" but I typed the code inside the parentheses totally wrong.
Grateful

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by