How can I involve options of all choice lists in a row of uitable in matlab GUI ?
1 次查看(过去 30 天)
显示 更早的评论
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);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197875/image.png)
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!