Azzera filtri
Azzera filtri

matching with data in cell array

50 visualizzazioni (ultimi 30 giorni)
Rya
Rya il 1 Giu 2017
Commentato: Walter Roberson il 10 Lug 2017
i want to match the output with data in cell array, i want to check whether the number(output) lies in cellarray or not?
  3 Commenti
Jan
Jan il 1 Giu 2017
@Rya: Andrei asked for a small example. You have posted your complete code with images, documentation, logos, auto-save files, several fig and m-files. What do you expect? That we inspect all of this code only to answer this simple question? The screenshot of the GUI is not useful here also.
You asked for "number(output) lies in cellarray". Then please provide how the number is represented and the typical contents or the cell array. Any further information is a waste of time only.
Rya
Rya il 1 Giu 2017
the number is stored in variable (noPlate) and output shows in editbox
set(handles.edit1,'string',noPlate);
here is a cell array ('ANPR.mat')
now how to check whether the output no lies in cell array or not

Accedi per commentare.

Risposte (2)

ES
ES il 1 Giu 2017
[truefalse, index] = ismember('abc', {'xyz', 'abc', 'def', 'abc'})
This one?
  12 Commenti
Walter Roberson
Walter Roberson il 10 Lug 2017
Note that you had
ANPR=['AED632' 'KPT295' 'AKH343' 'AFR420']; %cellarray
That does not create a cell array. You needed
ANPR={'AED632' 'KPT295' 'AKH343' 'AFR420'}; %cellarray
Walter Roberson
Walter Roberson il 10 Lug 2017
The suggested
nnz(ismember('EK94P8',ANPR(:,2)))
should be
nnz(ismember(ANPR(:,2), 'EK94P8'))
When you use ismember(A, B) then for each entry in A, a logical value (true or false) will be returned indicating whether that entry in A was found in B. So if you reverse the order like I show, then for each entry in your second column of ANPR, you are comparing it to the one value 'EK94P8', returning a logical value for each. The number of matches is the same as the number of places the logical value is true, which is the same as the number of places the logical value is non-zero. The number of places that a value is non-zero can be tested with nnz()

Accedi per commentare.


Jan
Jan il 1 Giu 2017
found = any(strcmp(TheNumber, TheListOfNumbers))
  5 Commenti
Rya
Rya il 3 Giu 2017
where is this button string name comes from i want to find a string is cell array (mat-file)
Rya
Rya il 3 Giu 2017
I m clear now @jan Thanq , will come up with new question :)

Accedi per commentare.

Categorie

Scopri di più su Workspace Variables and MAT-Files in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by