I want to save the output of an Editable Table after editing it

3 views (last 30 days)
function [Matrix_K] = Stiffness()
s=2;
Netot=32;
for i=1:10000
if s==2
[K_Row] = K_Row_fun;
keyboard
[Matrix_K,Int,s] = Element_Selection_K(K_Row,Netot)
Int=[Int;]
elseif s==1
break
end
end
--------------------------------------------------------------------------
function [K_Row] = K_Row_fun
disp('Insert stiffness matrix values');
K_Row=[0 0 0 0 0 0 0 0 0];
K_Matrix=zeros(3);
columnname = {'X', 'Y', 'Z'};
columnformat = {'numeric', 'numeric', 'numeric'};
rowname = {'X', 'Y', 'Z'};
h = figure('Position', [800 600 300 150]);
x = zeros(3);
mytable = uitable(h,'Data',x,...
'ColumnEditable',[true true true],...
'Position',[25 50 260 80],...
'ColumnName', columnname,...
'ColumnFormat',columnformat,...
'rowname',rowname);
set(h,'CloseRequestFcn',@myCloseFcn)
set(h,'Tag', 'myTag')
set(mytable,'Tag','myTableTag')
end
function [K_Matrix,K_Row]=myCloseFcn(~,~)
myfigure = findobj('Tag','myTag');
myData = get(findobj(myfigure,'Tag','myTableTag'),'Data');
assignin('base','K_Row',myData)
delete(myfigure)
K_Matrix=myData
K_Row=[ K_Matrix(1,1) K_Matrix(2,2) K_Matrix(3,3) K_Matrix(1,2) K_Matrix(1,3) K_Matrix(2,3) K_Matrix(2,1) K_Matrix(3,1) K_Matrix(3,2) ]
end
------------------------------------------------------------------
function [Matrix_K,Int,s] = Element_Selection_K(K_Row,Netot)
% Selezione elementi da analizzare con le teorie scelte
Matrix_K=zeros(Netot,9)
Int=[];
choice = questdlg('do you want to apply this choice to all the elements?', ...
'Elements', ...
'Yes','No','No');
switch choice
case 'Yes'
disp('The choice has been selected for all the elements')
s =1;
case 'No'
disp('Choose the Elements')
s=2;
end
if s == 1
Out_K = repmat(K_Row,Netot,1);
[r,c]=size(Out_K);
xpos=1;ypos=1;
Matrix_K(xpos:xpos+r-1,ypos:ypos+c-1)=Out_K;
Int=[];
elseif s == 2
for i=1:10000
First_element = input('Choose the first element of the interval: ');
if First_element==-1
break
end
Last_element = input('Choose the last element of the interval: ');
Int=[Int;First_element,Last_element;]
Netot = Last_element-First_element+1;
Out_K = repmat(K_Row,Netot,1);
[r,c]=size(Out_K); %sostituzione matrice K nella connectivity
xpos=First_element;ypos=1;
Matrix_K(xpos:xpos+r-1,ypos:ypos+c-1)=Out_K;
end
end
---------------------------------------------------------------------
I have this problem: when Matlab ends the K_Row_fun after editing the table, the output K_Row is different from [0 0 0 ...] but when it returns to the main script the K_Row becomes [0 0 0 ...]. I cant understand why. Please help me.

Accepted Answer

Walter Roberson
Walter Roberson on 25 Aug 2015
  2 Comments
Fedeone
Fedeone on 25 Aug 2015
Thak you. Do you know how can I save the edited table data?
Walter Roberson
Walter Roberson on 25 Aug 2015
The link I posed shows several ways. For example using guidata() or setappdata(). Or you could leave it in the uitable and get() it out of the table when you need it.

Sign in to comment.

More Answers (0)

Categories

Find more on Numeric Types in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!