Hello,
I have a reference cell(ref) which contains many postal codes and the corresponding geographic coordinate for each postal code. I wish to find the geographic coordinate for each postal code in cell A by using ref Cell. So I want to get B. Is there any way to do it *without making loop * over the elements in A?
ref={{'m3m1f1';'y9h5g5';'u8h1h5'} {50.00;50.44;30.98}}
A={{'y9h5g5';'m3m1f1'}}
B={{50.44;50.00}}
thanks in advance!

1 commentaire

Matt Fig
Matt Fig le 11 Sep 2012
Your ref cell looks wrong. You have 3 postal codes but 4 coordinates. Please correct this and post something I can copy/paste into the command window without editing...

Connectez-vous pour commenter.

 Réponse acceptée

Matt Fig
Matt Fig le 11 Sep 2012
Modifié(e) : Matt Fig le 11 Sep 2012

0 votes

ref = {{'m3m1f1';'y9h5g5';'u8h1h5'}; {50.00;50.44;30.98}};
A = {'y9h5g5';'m3m1f1'};
[J,J] = ismember(A,ref{1}); % Or A{1} if you need to keep {{}}.
B = ref{2}(J) % Or B = {ref{2}(J)} if you need to have{{}}.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by