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:
Last value in a column

Subject: Last value in a column

From: Etienne O'Brien

Date: 18 Nov, 2010 17:30:26

Message: 1 of 7

How can I find the last/final value (L) of a column in a dataset containing an unknown number of rows? 'L' may not necessarily be the maximum or minimum value in that column so I cannot use min/max functions.

Thank you.

Subject: Last value in a column

From: Jeff Gullett

Date: 18 Nov, 2010 17:42:04

Message: 2 of 7

"Etienne O'Brien" <etienneobrien@yahoo.com> wrote in message <ic3nri$8rs$1@fred.mathworks.com>...
> How can I find the last/final value (L) of a column in a dataset containing an unknown number of rows? 'L' may not necessarily be the maximum or minimum value in that column so I cannot use min/max functions.
>
> Thank you.

data = [0 1 8 9 6];
data(end) = 7;

% data now = [0 1 8 9 7]

Subject: Last value in a column

From: Sean de

Date: 18 Nov, 2010 17:45:06

Message: 3 of 7

"Etienne O'Brien" <etienneobrien@yahoo.com> wrote in message <ic3nri$8rs$1@fred.mathworks.com>...
> How can I find the last/final value (L) of a column in a dataset containing an unknown number of rows? 'L' may not necessarily be the maximum or minimum value in that column so I cannot use min/max functions.
>
> Thank you.

L = data(end,end);

Subject: Last value in a column

From: dpb

Date: 18 Nov, 2010 17:45:33

Message: 4 of 7

Etienne O'Brien wrote:
> How can I find the last/final value (L) of a column in a dataset
> containing an unknown number of rows? 'L' may not necessarily be the
> maximum or minimum value in that column so I cannot use min/max
> functions.
> Thank you.

doc end

is of course the cleanest way. But, in the vein of always more than one
way to skin a cat, there's

doc length

--

Subject: Last value in a column

From: Etienne O'Brien

Date: 18 Nov, 2010 18:14:04

Message: 5 of 7

Thank you Jeff and Sean,

However, L=data(end, end) gives me the value of the last row in the last column. The value I want is in another column - how can I specify this requirement?

Subject: Last value in a column

From: dpb

Date: 18 Nov, 2010 18:10:54

Message: 6 of 7

Etienne O'Brien wrote:
> Thank you Jeff and Sean,
>
> However, L=data(end, end) gives me the value of the last row in the last
> column. The value I want is in another column - how can I specify this
> requirement?

x(end,3) % say...

--

Subject: Last value in a column

From: Etienne O'Brien

Date: 19 Nov, 2010 18:18:04

Message: 7 of 7

Thank you, dpb

Etienne

Tags for 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