Azzera filtri
Azzera filtri

Determining the second last row

5 visualizzazioni (ultimi 30 giorni)
John
John il 16 Mar 2012
Hi there,
How would you code the number of rows minus one? Below I use size() to find the number of rows, but I want to set nrows to the number or rows minus 1.
Many thanks
sch_cycle=xlsread('C:\Autonomie practice\cycle.xls','Input_data');
nrows = size(sch_cycle,1);

Risposta accettata

Jonathan Sullivan
Jonathan Sullivan il 16 Mar 2012
sch_cycle=xlsread('C:\Autonomie practice\cycle.xls','Input_data');
nrows = size(sch_cycle,1)-1;

Più risposte (1)

Dr. Seis
Dr. Seis il 16 Mar 2012
If you mean you want to set "sch_cycle" to have nrows - 1, then no need to actually determine "nrows" beforehand (just use "end"):
sch_cycle = sch_cycle(1:end-1,:);
You can setup an "if" statement in order to make sure "nrows" is greater than 1.
  3 Commenti
Dr. Seis
Dr. Seis il 16 Mar 2012
Looks like "end" will still work there, too:
sch_cycle(1:max(1,end-1),:); % For all rows except last row
sch_cycle(max(1,end-1),:); % For just second to last row
John
John il 16 Mar 2012
Thanks for all the suggestions guys.

Accedi per commentare.

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by