Need Help for fprintf

조회 수: 1 (최근 30일)
Blaze Dexter
Blaze Dexter 2021년 2월 28일
댓글: Blaze Dexter 2021년 2월 28일
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 :)

채택된 답변

KSSV
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
  댓글 수: 1
Blaze Dexter
Blaze Dexter 2021년 2월 28일
thanks man it really helps me :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by