using fprintf to print selected rows from an excel file?

3 visualizaciones (últimos 30 días)
Anjum Syed
Anjum Syed el 6 de Sept. de 2016
Respondida: Keith Hooks el 6 de Sept. de 2016
i'm trying to use fprintf to print all three columns of an excel file, but only the first five rows. how do i go about this? thank you.
  2 comentarios
Walter Roberson
Walter Roberson el 6 de Sept. de 2016
Insufficient information about the data types of the columns. Does "first five rows" include one or more header lines? Are any of the columns dates?
Anjum Syed
Anjum Syed el 6 de Sept. de 2016
sorry, i should've clarified - yes, there are header lines, but i meant the first five lines of data. my xlsread code reads like this:
q = xlsread('G:\file.xlsx','sheet','A2:C7') with A2:37 being all 6 rows and 3 columns of data.

Iniciar sesión para comentar.

Respuestas (1)

Keith Hooks
Keith Hooks el 6 de Sept. de 2016
You could do something like this:
[len, width] = size(q);
for row = 1:len
fprintf('%d %s %s\n', q{row,1}, q{row,2}, q{row,3})
end
I made some assumptions about your data types. You might want to customize the %d, %s placeholders to your needs.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by