Need Help for fprintf
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Blaze Dexter
am 28 Feb. 2021
Kommentiert: Blaze Dexter
am 28 Feb. 2021
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 Kommentare
Akzeptierte Antwort
KSSV
am 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!