Need Help for fprintf

4 次查看(过去 30 天)
Blaze Dexter
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

更多回答(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