필터 지우기
필터 지우기

Displaying Array Data

조회 수: 1 (최근 30일)
luke
luke 2011년 5월 31일
I have a data array that has this format. >> whos DATA_matrix Name Size Bytes Class Attributes
DATA_matrix 756806x8 48435584 double
I am trying to loop thru the first 10 rows of data and display it like it shows up in the variable window.
for i = 1:10
for j = 1:8
sprintf('%8f',DATA_matrix(i,j))
end
end
When I run this code it prints out like
ans =
0.000000
ans =
27.000000
How do I get it to pint out each row on a separate line?

채택된 답변

Jan
Jan 2011년 5월 31일
for i = 1:10
for j = 1:8
fprintf('%8f ', DATA_matrix(i, j));
end
fprintf('\n');
end
It is faster and simpler to call FPRINTF with a vector:
for i = 1:10
fprintf('%8f ', DATA_matrix(i, 1:8));
fprintf('\n');
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Management에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by