cell array and uitable
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I cant quite see where I am going wrong with copying the contents of a uitable.
s=get(handles.uitable1,'data'); % get data from table
str = []; % Initalise
ab = s' %transpose so the values arrive in the right order for the 2nd sprintf
str = sprintf('%s\t%s\t%s\t%s\t%s\n', ab{:, 1}) %print first row exclusively as text
str = [str sprintf('%s\t%s\t%s\t%s\t%s\t%.4f\n', ab{:, 2:end})]
clipboard('copy',str);
My data is of the form cell array:
s =
'R01C01' [2] [2] [100] [100]
'R02C01' [3] [3] [ 67] [ 67]
'R03C01' [4] [3] [100] [100]
'R04C01' [3] [2] [ 67] [100]
'R05C01' [4] [4] [100] [100]
'R06C01' [4] [4] [100] [100]
'R07C01' [6] [4] [ 83] [100]
'R08C01' [4] [5] [100] [ 80]
Thanks for any help. Jason
0 Kommentare
Akzeptierte Antwort
Voss
am 24 Sep. 2023
Perhaps one of these methods.
s = {
'R01C01' 2 2 100 100
'R02C01' 3 3 67 67
'R03C01' 4 3 100 100
'R04C01' 3 2 67 100
'R05C01' 4 4 100 100
'R06C01' 4 4 100 100
'R07C01' 6 4 83 100
'R08C01' 4 5 100 80
}
% with tabs between data:
str = [sprintf('%s\t',s{:,1}) sprintf('\n') ...
sprintf([repmat('%d\t',1,size(s,1)) '\n'],s{:,2:end})]
% with fixed-width fields and a space between:
str = [sprintf('%8s ',s{:,1}) sprintf('\n') ...
sprintf([repmat('%8d ',1,size(s,1)) '\n'],s{:,2:end})]
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!