I want to save the output of an Editable Table after editing it
3 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Walter Roberson
2015-8-25
Callbacks such as CloseRequestFcn cannot return values.
2 个评论
Walter Roberson
2015-8-25
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!