Re: Matching Pairs (playing with arrays)



dc wrote:
>
>
> Hi all,
>
> I am curious if anyone has any experience with this, or if a
> function
> has been created for it. Basically, from two arrays of equal or
> unequal lengths, I want to match the closest values to each other.
> For instance:
>
> x = [5 3 1 4 2];
> y = [1.1 2.1 3.1 4.1 5.1];
> would match: 1 with 1.1, 2 with 2.1, etc.
>
> Thanks,
> DC

Assuming this is not a homework problem...

for i=1:length(x)
yclosest2x(i) = min(y>x(i));
end;
.



Relevant Pages

  • Re: Matching Pairs (playing with arrays)
    ... > unequal lengths, I want to match the closest values to each other. ... With equal lengths it's quite easy: ... Prev by Date: ...
    (comp.soft-sys.matlab)
  • Matching Pairs (playing with arrays)
    ... from two arrays of equal or ... unequal lengths, I want to match the closest values to each other. ... Prev by Date: ...
    (comp.soft-sys.matlab)
  • Re: Matlab question
    ... >> i dont even know where to start. ... > Why not post it on a newsgroup and hope someone else can be ... > do your homework for you? ... Prev by Date: ...
    (comp.soft-sys.matlab)
  • Re: Proper group for heatsink question?
    ... >> They've given a fairly large grant for this to be considered 'homework'. ... >> Thought I could get some general suggestions here for a thermal compound ... >mechanical adhesion or is simply required as ... Prev by Date: ...
    (sci.electronics.basics)
  • Re: Proper group for heatsink question?
    ... > They've given a fairly large grant for this to be considered 'homework'. ... You still haven't even mentioned if the 'thermal compound' has to provide ... mechanical adhesion or is simply required as ... Prev by Date: ...
    (sci.electronics.basics)