Need Help for fprintf
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello, i want to ask some questions, i have a data that look like this:
1 10 100 1000 10000
2 20 200 2000 20000
3 30 300 3000 30000
the goal is i want to present the data with this result :
1
10 - 100
1000 , 10000
2
20 - 200
2000 , 20000
3
30 - 300
3000 , 30000
and here is the script i made:
table=load('createsample.txt');
a = table(:,1);
b = table(:,2);
c = table(:,3);
d = table(:,4);
e = table(:,5);
fprintf('%d\n%d - %d\n%d , %d\n\n',a,b,c,d,e);
but the result is not yet there, anyone can help me with this? thanks in advance, hope you all stay healthy during this pandemic era :)
댓글 수: 0
채택된 답변
KSSV
2021년 2월 28일
% data = importdata(filename) ;
data = [1 10 100 1000 10000
2 20 200 2000 20000
3 30 300 3000 30000] ;
[m,n] = size(data) ;
for i = 1:m
fprintf('%d\n',data(i,1)) ;
fprintf('%d - %d\n',data(i,2),data(i,3)) ;
fprintf('%d, %d\n',data(i,4),data(i,5)) ;
fprintf('\n')
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!