How can I involve options of all choice lists in a row of uitable in matlab GUI ?

조회 수: 2 (최근 30일)
Omid Rezapour
Omid Rezapour 2018년 10월 14일
편집: Luna 2018년 10월 17일
I made a matlab gui that have two uitable, first table have choice list in its cells and second table have numeric format for its cells. The outputs are obtained from another gui (by pressing "Calculation" button). When we select option on each choice list (each column) in first table and press "Apply" button, the outputs set on second table, but when option of next choice list (next column)is selected and press "Apply" button, previous outputs are deleted. In other words if I select "Vertical" on first choice list (cell[1,1]) and press "Apply", the number for example "100" set on the "Vertical" column, but when I select "Lateral" on next choice list, the number for example "200" set on the "Lateral" column and the number "100" is transformed to zero. I need previous outputs (for example "100") remain in the second table and do not transformed to zero. here is my code : % --- Executes on button press in Apply. function Apply_Callback(hObject, eventdata, handles) % hObject handle to Apply (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
Fz1max = evalin('base','Fz1max'); Fy1max = evalin('base','Fy1max'); VerDisp = evalin('base','VerDisp'); BrakingFor = evalin('base','BrakingFor');
sourcedata = get(handles.uitable1, 'data'); newdata = get(handles.uitable2, 'data'); options = {'Vertical', 'Lateral', 'Twist','Braking'}; for i = 1:5 switch sourcedata{i,1} case options{1} newdata(i,:) = { Fz1max,0,0,0,0 }; case options{2} newdata(i,:) = { 0,Fy1max,0,0,0 }; case options{3} newdata(i,:) = { 0,0,VerDisp,0,0 }; case options{4} newdata(i,:) = { 0,0,0,BrakingFor,0 }; end switch sourcedata{i,2} case options{1} newdata(i,:) = { Fz1max,0,0,0,0 }; case options{2} newdata(i,:) = { 0,Fy1max,0,0,0 }; case options{3} newdata(i,:) = { 0,0,VerDisp,0,0 }; case options{4} newdata(i,:) = { 0,0,0,BrakingFor,0 }; end switch sourcedata{i,3} case options{1} newdata(i,:) = { Fz1max,0,0,0,0 }; case options{2} newdata(i,:) = { 0,Fy1max,0,0,0 }; case options{3} newdata(i,:) = { 0,0,VerDisp,0,0 }; case options{4} newdata(i,:) = { 0,0,0,BrakingFor,0 }; end end set(handles.uitable2, 'data',newdata);

답변 (1개)

Luna
Luna 2018년 10월 17일
편집: Luna 2018년 10월 17일
Hi Omid,
You should be creating your uitable and GUI inherited from the handle class if you want to hold your previous data of your objects.
See the attached example I have created for your case.
Please see the documentation on:

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품


릴리스

R2014a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by