Need Help for fprintf
5 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
KSSV
on 28 Feb 2021
% 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
More Answers (0)
See Also
Categories
Find more on Tables in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!