Create a "Copy-Button" in MATLAB GUI

8 Ansichten (letzte 30 Tage)
Tim Schaller
Tim Schaller am 14 Feb. 2023
Kommentiert: Tim Schaller am 15 Feb. 2023
Hi,
i created a Matlab GUI and I need to add a button to copy the data that is presented in the uitable.
I need to create a matrix that contains als the three-dimensional ponits. So it needs to look like the uitable that in the attached fig-file, but the columns are seperated by comma.
I hope that somebody knows what I am looking for.
Thnaks in advance.

Antworten (1)

Voss
Voss am 14 Feb. 2023
(I modified your m-file to include pushbutton_Callback and pushbutton2_Callback in the handles structure so I could run those functions here in the Answers forum.)
h = bachelor;
handles = guidata(h);
handles.pushbutton_Callback(handles.figure1,[],handles) % same as clicking the "Calculate" button
I added a single line to pushbutton2_Callback, which is "get(handles.table1,'Data')", so that when the "Copy Data" button is pushed the contents of the uitable are displayed in the command window.
handles.pushbutton2_Callback(handles.figure1,[],handles) % same as clicking the "Copy Data" button
ans = 195×3
0 0 1.000000000000000 0.017150418627992 0 0.823370357174576 0.072731407686129 0 0.654969826345343 0.167425334872282 0 0.505049838368501 0.293716496272837 0 0.380416474388619 0.441054925718054 0 0.281320429539904 0.601052703191758 0 0.204120675587443 0.768451294767690 0 0.144506893175706 0.940201848235069 0 0.098822798983855 1.114545504736437 0 0.064258683622423
It sounds like that's the matrix you want to create.
Do you want to do something else with it?
  3 Kommentare
Tim Schaller
Tim Schaller am 15 Feb. 2023
And another problem would be that the matrix in the command window is shortened by the factor 100. So right know I need to multiply the matrix by 100 to get the points I want.
Tim Schaller
Tim Schaller am 15 Feb. 2023
I tried it by adding the following lines to the m-file:
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
abc = get(handles.uitable1,'Data')
clipboard('copy',abc)
In this case the matrix is automatically saved in the clipboard, but it looks like this know
[0 0 100;1.71504186279923 0 82.3370357174576;7.27314076861285 0 65.4969826345343;.........]
And this is not what i need as well.
I don't know if my problem is even realizible.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Migrate GUIDE Apps 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!

Translated by