From: Peter Smith on
Hi all, i posted this message moments ago

i am looping through a number of matrices, they all contain a vector tmptime

I want to tell matlab to delete all rows of tmptime after row 800
The length of rows vary between matrices.

How can i tell matlab to just delete after 800 rows without specifying the final row.

Please could someone help i am very stuck

Someone kindly replied tmpTime(800:end)=[]
However, some matrices do not have 800 rows, whilst some have significantly more.
I get an error message due to some not having 800 rows.

Is it possible to tell matlab, something like, if they exist, delete after 800 rows?

Please could someone help?
From: Walter Roberson on
Peter Smith wrote:

> Someone kindly replied tmpTime(800:end)=[]

I believe they used 801 not 800, as you wanted to delete the ones *after* 800.

> However, some matrices do not have 800 rows, whilst some have
> significantly more.
> I get an error message due to some not having 800 rows.
>
> Is it possible to tell matlab, something like, if they exist, delete
> after 800 rows?

tmpTime(min(800,end)+1:end) = [];
From: Matt J on
"Peter Smith" <fe09ae(a)mail.wbs.ac.uk> wrote in message <i446us$k4q$1(a)fred.mathworks.com>...


> However, some matrices do not have 800 rows, whilst some have significantly more.
> I get an error message due to some not having 800 rows.
>
> Is it possible to tell matlab, something like, if they exist, delete after 800 rows?
======

if length(tmpTime)>=800,
tmpTime=tmpTime(1:800);
end
From: Sean on
"Peter Smith" <fe09ae(a)mail.wbs.ac.uk> wrote in message <i446us$k4q$1(a)fred.mathworks.com>...
> Hi all, i posted this message moments ago
>
> i am looping through a number of matrices, they all contain a vector tmptime
>
> I want to tell matlab to delete all rows of tmptime after row 800
> The length of rows vary between matrices.
>
> How can i tell matlab to just delete after 800 rows without specifying the final row.
>
> Please could someone help i am very stuck
>
> Someone kindly replied tmpTime(800:end)=[]
> However, some matrices do not have 800 rows, whilst some have significantly more.
> I get an error message due to some not having 800 rows.
>
> Is it possible to tell matlab, something like, if they exist, delete after 800 rows?
>
> Please could someone help?


if size(matrix,1) >=800 %size of the matrix first dimension (i.e. number of rows)
delete...
end
From: Peter Smith on
Walter i am very greatful.