On Feb 18, 7:43 pm, Ross <fed.ro...@gmail.com> wrote:
> Hi everyone,
>
> I have two 2-dim arrays, A and C. C is zeros and ones.
> I and want to find min(A, [ ] , 2), but only considering elements that
> are ones in matrix C.
>
> Do you know a fast way to compute this in matlab?
>
> Thank you!
> Ross
ok, I guess I will go with the brute force:
a = max(max(A));
Ca = C.*a;
Amin = min(Ca+A,[ ],2);
Ross <fed.rossi@gmail.com> wrote in message
<b21b9772-12c9-4842-a58e-34c1fc28faff@v3g2000hsc.googlegroups.com>...
> On Feb 18, 7:43 pm, Ross <fed.ro...@gmail.com> wrote:
> > Hi everyone,
> >
> > I have two 2-dim arrays, A and C. C is zeros and ones.
> > I and want to find min(A, [ ] , 2), but only considering
elements that
> > are ones in matrix C.
> >
> > Do you know a fast way to compute this in matlab?
> >
> > Thank you!
> > Ross
>
> ok, I guess I will go with the brute force:
>
> a = max(max(A));
> Ca = C.*a;
> Amin = min(Ca+A,[ ],2);
>
B = A ; % work on a copy
B(C==0) = Inf ;
Amin = min(B,[],2)
> I have two 2-dim arrays, A and C. C is zeros and ones.
> I and want to find min(A, [ ] , 2), but only considering
elements that are ones in matrix C...
i looked at previous solutions in this thread - but still
don't understand what you want...
can you tell CSSM how the output of these exemplary
matrices should look like (assuming i understand your <two
2-dim> correctly)...
On Feb 19, 1:58 am, "Jos " <DEL...@jasenDEL.nl> wrote:
> Ross <fed.ro...@gmail.com> wrote in message
>
> <b21b9772-12c9-4842-a58e-34c1fc28f...@v3g2000hsc.googlegroups.com>...
>
>
>
> > On Feb 18, 7:43 pm, Ross <fed.ro...@gmail.com> wrote:
> > > Hi everyone,
>
> > > I have two 2-dim arrays, A and C. C is zeros and ones.
> > > I and want to find min(A, [ ] , 2), but only considering
> elements that
> > > are ones in matrix C.
>
> > > Do you know a fast way to compute this in matlab?
>
> > > Thank you!
> > > Ross
>
> > ok, I guess I will go with the brute force:
>
> > a = max(max(A));
> > Ca = C.*a;
> > Amin = min(Ca+A,[ ],2);
>
> B = A ; % work on a copy
> B(C==0) = Inf ;
> Amin = min(B,[],2)
>
> hth
> Jos
Hi Jos,
thank you for your message
I tried this method too, and I saw that matlab spends a lot of time
with this code. Maybe it is because the A matrix is huge or it is
sparse
On Feb 19, 2:16 am, "us " <u...@neurol.unizh.ch> wrote:
> Ross:
> <SNIP jiggling ones and zeros...
>
> > I have two 2-dim arrays, A and C. C is zeros and ones.
> > I and want to find min(A, [ ] , 2), but only considering
>
> elements that are ones in matrix C...
>
> i looked at previous solutions in this thread - but still
> don't understand what you want...
> can you tell CSSM how the output of these exemplary
> matrices should look like (assuming i understand your <two
> 2-dim> correctly)...
>
> a=[
> 10 20
> 30 30
> 50 50
> ];
> c=[
> 1 0
> 1 1
> 0 0
> ];
>
> us
Hi us, thanks for replying.
To be more precise, c is a matrix of zeros and ones such that sum(c,[],
2)>0
To follow your example, and adding a one to c so that c(3,1)=1,
the output would be d = [10 30 50]'
On Feb 19, 10:32 am, Ross <fed.ro...@gmail.com> wrote:
> On Feb 19, 2:16 am, "us " <u...@neurol.unizh.ch> wrote:
>
>
>
> > Ross:
> > <SNIP jiggling ones and zeros...
>
> > > I have two 2-dim arrays, A and C. C is zeros and ones.
> > > I and want to findmin(A, [ ] , 2), but only considering
>
> > elements that are ones in matrix C...
>
> > i looked at previous solutions in this thread - but still
> > don't understand what you want...
> > can you tell CSSM how the output of these exemplary
> > matrices should look like (assuming i understand your <two
> > 2-dim> correctly)...
>
> > a=[
> > 10 20
> > 30 30
> > 50 50
> > ];
> > c=[
> > 1 0
> > 1 1
> > 0 0
> > ];
>
> > us
>
> Hi us, thanks for replying.
> To be more precise, c is a matrix of zeros and ones such that sum(c,[],
> 2)>0
> To follow your example, and adding a one to c so that c(3,1)=1,
> the output would be d = [10 30 50]'
ok, I just discovered accumarray, which solves the problem
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.