Thread Subject: Extracting data

Subject: Extracting data

From: yingmu huadao

Date: 30 Dec, 2008 06:08:01

Message: 1 of 3

Hi all,

I have a variable, a = <1 x 102300 double>. How do I go about extracting data from every 4 numbers and store the data in another variable, for eg, the 1,5,9,13 (position) data, store in variable b.
Thanks in advance.

Yingmu

Subject: Extracting data

From: gcet03

Date: 30 Dec, 2008 07:29:08

Message: 2 of 3

clear all;
b=ones(1,length(a)/4);
c=0;
for i=1:length(a)
    if rem(i,4)==0
        c=c+1;
        b(c)=a(i);
    end
end

Run above code with your values in stored in a variable

Subject: Extracting data

From: Bruno Luong

Date: 30 Dec, 2008 08:03:03

Message: 3 of 3

"yingmu huadao" <yingmusg@yahoo.com.sg> wrote in message <gjcds1$8j7$1@fred.mathworks.com>...
> Hi all,
>
> I have a variable, a = <1 x 102300 double>. How do I go about extracting data from every 4 numbers and store the data in another variable, for eg, the 1,5,9,13 (position) data, store in variable b.
> Thanks in advance.
>
> Yingmu

b=a(1:4:end)

Bruno

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

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 Terms prior to use.

Contact us at files@mathworks.com