Compare editfield.value to table values in app designer

Hello.
I wanna make an app that is comparing a value(from editfield numeric) to a table imported from excel. The table has 3 columns (z , f , d). The value has to be found in the z column. If found, the f and d colums values coresponding to z has to be displayed. Can you help me? It's my first app made in app designer.

5 件のコメント

Mario Malic
Mario Malic 2021 年 6 月 16 日
Please see the tutorials and simple apps, or maybe program it without App Designer at first. Once you're able to write the code, you can easily move it to App Designer.
Steps:
  1. Import the file in a variable or table with readtable
  2. Compare a single value with vector elements a == b. Output is logical array that may have true values on some indices
  3. Use info from step two to return the values you need.
Andrei Iulian
Andrei Iulian 2021 年 6 月 16 日
Thank you for your response. I've searched and watched some tutorials about it, but i found nothing specific. I've imported the excel in app designer with readtable in a startupfcn. After that i though of using if function, but i don't know how to compare the variable to a table column(if i compare directly with == it says error matrix dimensions must agree).
Mario Malic
Mario Malic 2021 年 6 月 16 日
Data in UITable component is held in property Data which is an array, so access third column of it this way
idx = app.EditField.Value == app.UITable.Data(:,3);
Idx will give you logical array.
a = [1 2 3 4];
b = 2;
idxRow = find(b == a)
ans = 2
Use it to index into particular row of the Data.
Andrei Iulian
Andrei Iulian 2021 年 6 月 17 日
i tried this way, and it send me this error "Undefined function 'eq' for input arguments of type 'table'." .
What i specifically want to do is:
if(app.EditField.Value == app.UITable.Data(:,1) (if the value is found in the first column of the table)
app.EditField2.Value=app.UITable.Data(app.EditField.Value,2) (editfield2 gets the value of editfield row, column 2)
I wrote this as an example, i don't know how to write it corectly, that's why i need help.
Thank you!
Mario Malic
Mario Malic 2021 年 6 月 17 日
Show complete error. I don't see eq anywhere

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品

リリース

R2019a

質問済み:

2021 年 6 月 16 日

コメント済み:

2021 年 6 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by