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:
want to collect specific row values from an array

Subject: want to collect specific row values from an array

From: Moon Datta

Date: 4 Dec, 2012 11:16:08

Message: 1 of 3

I have two arrays in which one(A) is of 86400x1

and another(B) is of 3600x1

B array is created by the value of every 60th row of A.

e.g.
B(1,:)=A(60,:)

B(2,:)=A(120,:)

....................

in this way.

I have tried

for i=60:60:length(A)
    B(i,:) = A(i,:);
    end

Its giving me the B array but with 0 replace between every 60th value.

I need only the values with out any zero between them.

any help please.

Thanks in advance

Subject: want to collect specific row values from an array

From: Nasser M. Abbasi

Date: 4 Dec, 2012 11:37:29

Message: 2 of 3

On 12/4/2012 5:16 AM, Moon Datta wrote:
> I have two arrays in which one(A) is of 86400x1
>
> and another(B) is of 3600x1
>
> B array is created by the value of every 60th row of A.
>
> e.g.
> B(1,:)=A(60,:)
>

But you have one column only. Then why not just write


B(1)=A(60)

?

How about:

------------------
%data
M = 86400; N=3600;
A = rand(M,1);
B = rand(N,1);

%logic
idx = 0:60:M;
idx(1) = 1;
B = A(idx);
------------------

--Nasser

Subject: want to collect specific row values from an array

From: Jos (10584)

Date: 4 Dec, 2012 12:04:07

Message: 3 of 3

"Moon Datta" wrote in message <k9km1o$ng1$1@newscl01ah.mathworks.com>...
> I have two arrays in which one(A) is of 86400x1
>
> and another(B) is of 3600x1
>
> B array is created by the value of every 60th row of A.

B = A(60:60:end,:)

To understand this compare it to the following (smaller) example
A = floor(10*rand(12,3))
B = A(3:3:end,:) % every 3rd row of A

~ Jos

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