traversing an array of elements
Mostra commenti meno recenti
i've the following list of elements as
block 2=10
block 5=16
block 1= 16
block 7=16
block 4= 23
block 6=31
block 3= 31
i.e i've a total of 7 block numbers
the list is in sorted order...
i want to traverse it and find a match between block values like 'block 5', 'block 1' and 'block 7' match
'block 6' and 'block 3' match.. and print these blocks with matching values
how this can be done?
traversing a single list of array of following type i know like
function traverse
clc;
a=[ 1 2 2 3 3 4 4 4 4]
len=length(a)-1;
for i=1:len
if(a(i)==a(i+1))
fprintf('\n%d and %d\n',a(i),a(i+1));
end
end
but to deal with the above list i dont know help me in doing so....
8 Commenti
Walter Roberson
il 13 Mar 2013
Modificato: Walter Roberson
il 13 Mar 2013
Do you mean that you are starting with strings of that form? If so, what form are the strings stored in?
Walter Roberson
il 13 Mar 2013
I do not understand about your "above list of alphabets type" ?
Raman
il 13 Mar 2013
Walter Roberson
il 13 Mar 2013
You have corrected the length(a) now, as per your recent Question ?
So let a = YourPairsArray(:,1)
where YourPairsArray is the one that has [s,BlockNumber]
Raman
il 13 Mar 2013
Walter Roberson
il 13 Mar 2013
What is the name of your array that is of the form "[s,blockNumber]" ? Are the values in it stored by columns, so Array(2,1) is the second "s" value?
Raman
il 14 Mar 2013
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Image Arithmetic in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!