I have to trees with two-two nodes, and one table is linked to the tree. When I select the nodes first, it should show the values taken from a .mat file, in the table. I want to change some values of the nodes and save them in the same .mat file. It is saving different values to the nodes automatically, and sometimes I am getting an error "Dot indexing is not supported for variables of this type''. Below find the code of the app designer.
properties (Access = private) tab Dx Dy Dz IXX IYY IZZ end % Callbacks that handle component events
methods (Access = private) % Selection changed function: Tree
function TreeSelectionChanged(app, event) selectedNodes = app.Tree.SelectedNodes; app.tab = load('property.mat'); if strcmp(selectedNodes.Text,'Center of Mass') app.UITable.Data(1,1) = app.tab.dx(1); app.UITable.Data(2,1) = app.tab.dy(1); app.UITable.Data(3,1) = app.tab.dz(1); end if strcmp(selectedNodes.Text,'Inertia') app.UITable.Data(1,1) = app.tab.Ixx(1); app.UITable.Data(2,1) = app.tab.Iyy(1); app.UITable.Data(3,1) = app.tab.Izz(1); end end % Selection changed function: Tree_2
function Tree_2SelectionChanged(app, event) selectedNodes2 = app.Tree_2.SelectedNodes; app.tab = load('property.mat'); if strcmp(selectedNodes2.Text,'Center of Mass2') app.UITable.Data(1,1) = app.tab.dx(2); app.UITable.Data(2,1) = app.tab.dy(2); app.UITable.Data(3,1) = app.tab.dz(2); end if strcmp(selectedNodes2.Text,'Inertia2') app.UITable.Data(1,1) = app.tab.Ixx(2); app.UITable.Data(2,1) = app.tab.Iyy(2); app.UITable.Data(3,1) = app.tab.Izz(2); end end % Cell edit callback: UITable
function UITableCellEdit(app, event) selectedNodes = app.Tree.SelectedNodes; app.tab = load('property.mat'); if strcmp(selectedNodes.Text,'Center of Mass') app.Dx = app.UITable.Data(1,1); app.Dy = app.UITable.Data(2,1); app.Dz = app.UITable.Data(3,1); x1 = app.Dx; y1 = app.Dy; z1 = app.Dz; dx = [x1,app.tab.dx(2)]; dy = [y1,app.tab.dx(2)]; dz = [z1,app.tab.dx(2)]; Ixx = app.tab.Ixx; Iyy = app.tab.Iyy; Izz = app.tab.Izz; save('property.mat','dx','dy','dz','Ixx','Iyy','Izz'); end if strcmp(selectedNodes.Text,'Inertia') app.IXX = app.UITable.Data(1,1); app.IYY = app.UITable.Data(2,1); app.IZZ = app.UITable.Data(3,1); dx = app.tab.dx; dy = app.tab.dy; dz = app.tab.dz; Ixx1 = app.IXX; Iyy1 = app.IYY; Izz1 = app.IZZ; Ixx = [Ixx1,app.tab.Ixx(2)]; Iyy = [Iyy1,app.tab.Iyy(2)]; Izz = [Izz1,app.tab.Izz(2)]; save('property.mat','dx','dy','dz','Ixx','Iyy','Izz'); end selectedNodes2 = app.Tree_2.SelectedNodes; app.tab = load('property.mat'); if strcmp(selectedNodes2.Text,'Center of Mass2') app.Dx = app.UITable.Data(1,1); app.Dy = app.UITable.Data(2,1); app.Dz = app.UITable.Data(3,1); x2 = app.Dx; y2 = app.Dy; z2 = app.Dz; dx = [app.tab.dx(1),x2]; dy = [app.tab.dx(1),y2]; dz = [app.tab.dx(1),z2]; Ixx = app.tab.Ixx; Iyy = app.tab.Iyy; Izz = app.tab.Izz; save('property.mat','dx','dy','dz','Ixx','Iyy','Izz'); end if strcmp(selectedNodes2.Text,'Inertia2') app.IXX = app.UITable.Data(1,1); app.IYY = app.UITable.Data(2,1); app.IZZ = app.UITable.Data(3,1); dx = app.tab.dx; dy = app.tab.dy; dz = app.tab.dz; Ixx2 = app.IXX; Iyy2 = app.IYY; Izz2 = app.IZZ; Ixx = [app.tab.Ixx(1),Ixx2]; Iyy = [app.tab.Iyy(1),Iyy2]; Izz = [app.tab.Izz(1),Izz2]; save('property.mat','dx','dy','dz','Ixx','Iyy','Izz'); end end end
Best Answer