Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Ignoring matrix elements

Subject: Ignoring matrix elements

From: Chris McCorquodale

Date: 27 Jan, 2011 10:29:05

Message: 1 of 4

Hi,

I am wondering if theres any way to tell matlab to ignore certain matrix elements (e.g. ignore highest 50 elements or lowest 30 elements).

The reason I'm asking is because I believe I have some mesh artefacts from FEA that are making my matlab calculations invalid.

Thanks

Chris

Subject: Ignoring matrix elements

From: Jos (10584)

Date: 27 Jan, 2011 10:58:04

Message: 2 of 4

"Chris McCorquodale" wrote in message <ihrhdh$be8$1@fred.mathworks.com>...
> Hi,
>
> I am wondering if theres any way to tell matlab to ignore certain matrix elements (e.g. ignore highest 50 elements or lowest 30 elements).
>
> The reason I'm asking is because I believe I have some mesh artefacts from FEA that are making my matlab calculations invalid.
>
> Thanks
>
> Chris

There are two options:
1) discarding
2) replacing

Example
Data = [1 2 3 4 5 6 7 8 9] ;% but data points larger than 7 are "wrong"

% option 1: discard
q = Data > 7 ; % true if to-be-ignored
validData = Data(~q) % discard
mean (validData)

% options 2: replace
q = Data > 7 ;
validData = Data ; % work on a copy!
validData(q) = NaN
nanmean(validData) % note the need for a special functions to treat Nans properly

hth
Jos

Subject: Ignoring matrix elements

From: Jan

Date: 27 Jan, 2011 11:01:10

Message: 3 of 4

Perhaps something like this will work:

[ ~, ind ] = sort( yourMatrix, 'descend' );

plot( yourMatrix( ind( 51 : end ) ) ); % ignore 50 largest elements
plot( yourMatrix( ind( 1 : end - 30 ) ) ); % ignore 30 smallest elements

Subject: Ignoring matrix elements

From: Jan

Date: 27 Jan, 2011 11:04:05

Message: 4 of 4

Perhaps something like this will work:

[ ~, ind ] = sort( yourMatrix, 'descend' );

plot( yourMatrix( ind( 51 : end ) ) ); % ignore 50 largest elements
plot( yourMatrix( ind( 1 : end - 30 ) ) ); % ignore 30 smallest elements

Tags for this Thread

No tags are associated with this thread.

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.

Contact us