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 Comments

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.
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).
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.
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!
Show complete error. I don't see eq anywhere

Sign in to comment.

Answers (0)

Products

Release

R2019a

Asked:

on 16 Jun 2021

Commented:

on 17 Jun 2021

Community Treasure Hunt

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

Start Hunting!