MATLAB Answers

0

My file compiled .exe does not run as it should.

Pedro Guevara さんによって質問されました 2019 年 7 月 21 日
最新アクティビティ Walter Roberson
さんによって コメントされました 2019 年 7 月 26 日
Good morning. I have the following problem I have 4 file files: form1.fig form1.m form2.fig form2.m I'm trying to make a single compiled .exe file with these 4 files, but I can not get the actions contained within form2.fig and form2.m to run. There are calculated data that must be transferred from the form1.ma form2.my and I am using the function (eval) in form1.m (which according to the documentation could give problems when compiling, however I do not see that is affecting the compilation corresponding to the form1.m) When executing my files inside MATLAb there are no problems in the execution, I do not know why in the compiler if there are problems. If you think it is necessary, I leave the files in the post for analysis. Thank you very much for your help.

  6 件のコメント

Walter Roberson
2019 年 7 月 24 日
Which toolboxes are you using? In particular are you using Symbolic toolbox? That cannot be compiled.
If you attach your code and fig here probably someone will look at it, assuming it has some comments. (People tend to give up quickly on long uncommented code)
Pedro Guevara 2019 年 7 月 24 日
If I have a part where I use functions of symbolic order for the clearance of a polynomial equation. Could it be that?
I am using a symbolic variable "w" and functions such as: "sym2poly" and "roots"
Pedro Guevara 2019 年 7 月 24 日
And this is all my GUI 2 code:
function varargout = form2(varargin)
% FORM2 MATLAB code for form2.fig
% FORM2, by itself, creates a new FORM2 or raises the existing
% singleton*.
%
% H = FORM2 returns the handle to a new FORM2 or the handle to
% the existing singleton*.
%
% FORM2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FORM2.M with the given input arguments.
%
% FORM2('Property','Value',...) creates a new FORM2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before form2_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to form2_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help form2
% Last Modified by GUIDE v2.5 09-Jun-2019 11:05:47
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @form2_OpeningFcn, ...
'gui_OutputFcn', @form2_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before form2 is made visible.
function form2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to form2 (see VARARGIN)
% Choose default command line output for form2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
%mcc -m form1.m;
%-------------------------------------------------------
global NP
global TTT
global Kss
global Ksp
global NCKss
global NFKss
global NCKsp
global NFKsp
global MRT
global NodosT
global VarElem_F
global Nodos_cim
handles.form1_h = findobj(groot, 'tag', 'form1');
handles1 = guidata(handles.form1_h); %this is form1's handles
handles.data_form2_needs = handles1.data_form2_will_need; % pasa KC
handles.data_form2_needs_KSS = handles1.data_form2_will_need_Kss;% pasa Kss
handles.data_form2_needs_KSP = handles1.data_form2_will_need_Ksp;% pasa Ksp
handles.data_form2_needs_NCKss = handles1.data_form2_will_need_NCKss;% pasa Nodos Kss (Colum)
handles.data_form2_needs_NFKss = handles1.data_form2_will_need_NFKss;% pasa Nodos Kss (Filas)
handles.data_form2_needs_NCKsp = handles1.data_form2_will_need_NCKsp;% pasa Nodos Ksp (Colum)
handles.data_form2_needs_NFKsp = handles1.data_form2_will_need_NFKsp;% pasa Nodos Ksp (Filas)
handles.data_form2_needs_MRT = handles1.data_form2_will_need_MRT;% pasa MRT
handles.data_form2_needs_NodosT = handles1.data_form2_will_need_NodosT;% pasa NODOS
handles.data_form2_needs_NumElem = handles1.data_form2_will_need_NumElem;% pasa NumEle
handles.data_form2_needs_Nodos_cim =handles1.data_form2_will_need_Nodos_cim; % pasa Nodos de cimentacion.
guidata(hObject, handles)
TTT=handles.data_form2_needs;
Kss=handles.data_form2_needs_KSS;
Ksp=handles.data_form2_needs_KSP;
NCKss=handles.data_form2_needs_NCKss;
NFKss=handles.data_form2_needs_NFKss;
NCKsp=handles.data_form2_needs_NCKsp;
NFKsp=handles.data_form2_needs_NFKsp;
MRT=handles.data_form2_needs_MRT;
NodosT=handles.data_form2_needs_NodosT;
VarElem_F=handles.data_form2_needs_NumElem;
Nodos_cim=handles.data_form2_needs_Nodos_cim;
guidata(hObject, handles)
NumPiso= length ( TTT ( : , 1 ) ) - 1 ;
num_elem=cell(NumPiso,2);
num_elem(:,:)={''};
set(handles.TablaMasa,'Data',num_elem);
NP=NumPiso;
% --- Executes on button press in CalcularDin.
function CalcularDin_Callback(hObject, eventdata, handles)
% hObject handle to CalcularDin (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
syms w
global datos
global NP
global TTT
global Kss
global Ksp
global NCKss
global NFKss
global NCKsp
global NFKsp
global MRT
global NodosT
global VarElem_F
global Nodos_cim
% TTT = KC. KC ESTA EN MN/m
datos=get(handles.TablaMasa,'Data');
datos=str2double([datos(1:NP,1:2)]);
datos=sortrows(datos,'descend');
Cant_port=str2double(get(handles.Can_port_label,'string'));
for j=1:NP
v_masa (j,1) = datos (j,2) ;
end
Matriz_masa = diag(v_masa);
Ecua=det((10^6)*Cant_port*TTT(1:NP,1:NP) - (w^2)*Matriz_masa );
Ecua=sym2poly (Ecua);
sol_frec=roots(Ecua);
sol_frec= sol_frec (sol_frec >= 0);
sol_frec =sort (sol_frec);
% -------LLena modos
for f=1:NP
tabla_modos(f,1)=f;
end
% -------LLena w
for f=1:NP
tabla_modos(f,2)= sol_frec (f,1);
end
% -------LLena f
for f=1:NP
tabla_modos(f,3)= (tabla_modos(f,2))/(2*3.141592) ;
end
% -------LLena T
for f=1:NP
tabla_modos(f,4)= ((2*3.141592)/ tabla_modos(f,2)) ;
end
%----------------------------------------------------------------
% -------Determinacion de modos de vibracion---------------------
%----------------------------------------------------------------
sol_frec=sol_frec;
Modos=[];
XonT = zeros(NP+1) ;
XonT_C= cell(NP+1,NP+1)
menospiso=0;
for f=1:NP
Modos = (TTT(1:NP,1:NP)*(10^6)*Cant_port) - ((sol_frec(f,1))^2)*Matriz_masa ;
EO1= Modos(2:NP, 1);
EOO= Modos(2:NP, 2:NP);
Xon = inv(EOO)*(-1)*(EO1);
Xon =[1;Xon];
XonT (1:NP, f) = Xon ;
XonT_C (:, f) = [ num2cell(Xon) ; ['Mod',num2str(f)] ] ;
XonT_C {f, NP+1} = ['Piso ',num2str(NP-menospiso)] ;
menospiso=menospiso+1;
end
%----------------------------------------------------------------
% -------Normalizacion de modos de vibracion---------------------
%----------------------------------------------------------------
v_masa=v_masa; % del piso mas alto al los mas bajos
Aux=0;
den = zeros(NP,1);
Modos= zeros(NP,NP);
Modos_C = cell(NP+1,NP+1);
menospiso=0;
ModosCol= zeros(NP,1);
for c=1:NP
for f=1:NP
Aux = v_masa(f,1)* ( XonT ( f , c ) )^2 + Aux;
den (c,1) = ( Aux )^0.5;
end
for f=1:NP
Modos( f , c ) = XonT(f , c ) / den ( c , 1 ) ;
ModosCol (f,1)= Modos( f , c );
end
Modos_C (:, c) = [ num2cell(ModosCol) ; ['Mod',num2str(c)] ] ;
Modos_C {c, NP+1} = ['Piso ',num2str(NP-menospiso)] ;
menospiso=menospiso+1;
Aux=0;
end
%----------------------------------------------------------------
% -------Coeficientes de participacion---------------------------
%----------------------------------------------------------------
porc_masa_total= zeros(NP,NP); %modo y %masa
Coe_par = zeros (NP,1) ;
vector_unos = ones (NP,1);
Modos_C_T = transpose(Modos_C); % BORRAR AL FINAL
Coe_par = -transpose(Modos)* Matriz_masa * vector_unos ; %--->COE DE PART MODAL (R): DEL PASO 6. Del el modo mas Bajo al mas Alto.
Coe_par_cua= power(Coe_par,2);
for f=1:NP
porc_masa_total (f,1) = f ;
porc_masa_total (f,2) = (Coe_par_cua (f,1) ) / sum(Coe_par_cua) ; %modo y %masa
end
%----------------------------------------------------------------
% -------Determinacion de valores de espectro de diseño----------
%----------------------------------------------------------------
%-----Label a variables--------------
Fv=str2double(get(handles.Fv_Label,'string'));
Fa=str2double(get(handles.Fa_Label,'string'));
Aa=str2double(get(handles.Aa_Label,'string'));
Av=str2double(get(handles.Av_Label,'string'));
I=str2double(get(handles.I_Label,'string'));
%--------------To---------------------
To= 0.1*((Av*Fv)/(Aa*Fa));
%--------------Tc---------------------
Tc= 0.48*((Av*Fv)/(Aa*Fa));
%--------------Tl---------------------
Tl= 2.4*Fv;
%---Condiciones para hallar Sa---------
tabla_modos=tabla_modos; % 4º Columna es el periodo
Sa_C= cell(NP,2);
for f=1:NP
if (tabla_modos (f,4)) <= To
if tabla_modos (f,1)~= 1
Sa(f,1)=2.5*Aa*Fa*I*(0.4+0.6*( ( (tabla_modos (f,4)) ) / To ));
Sa_C (f, :) = [ num2cell(Sa(f,1)) , ['Mod',num2str(f)] ] ;
else
Sa(f,1)=2.5*Aa*Fa*I;
Sa_C (f, :) = [ num2cell(Sa(f,1)) , ['Mod',num2str(f)] ] ;
end
elseif ( (tabla_modos (f,4))> To && (tabla_modos (f,4)) <= Tc )
Sa(f,1)=2.5*Aa*Fa*I;
Sa_C (f, :) = [ num2cell( Sa(f,1) ) , ['Mod',num2str(f)] ] ;
elseif ( (tabla_modos (f,4))> Tc && (tabla_modos (f,4)) <= Tl )
Sa(f,1) = ( 1.2*Av*Fv*I )/ (tabla_modos (f,4)) ;
Sa_C (f, :) = [ num2cell(Sa(f,1)) , ['Mod',num2str(f)] ] ;
elseif (tabla_modos (f,4)) > Tl
Sa(f,1)= ( 1.2*Av*Fv*Tl*I )/ ((tabla_modos (f,4)))^2 ;
Sa_C (f, :) = [ num2cell(Sa(f,1)) , ['Mod',num2str(f)] ] ;
end
end
%*******Mostrar Sa en Msgbox******************
% now as you know this matrix is in cell format so can not be display in msgbox
% so we need to convert it into string or char format, as follows..
[row, column] = size (Sa_C);
% below logic to find the max length of all digits or strings in matrix
maxLength = 0;
for count1 = 1:row
for count2 = 1:column
maxLength = max (length (num2str (Sa_C {count1,count2})),maxLength);
end
end
% below logic to make all values or string to be of same length, so I am adding spaces.
for count1 = 1:row
for count2 = 1:column
if maxLength == length (num2str (Sa_C{count1,count2}))
Sa_C_temp {count1,count2} = num2str (Sa_C{count1,count2});
else
diff1 = maxLength - length (num2str (Sa_C{count1,count2}));
Sa_C_temp {count1,count2} = num2str (Sa_C{count1,count2});
for i=1:diff1
Sa_C_temp {count1,count2} = [' ',Sa_C_temp{count1,count2}];
end
end
end
end
[row, column] = size (Sa_C_temp);
finalStringtoDisplay = '';
% below logic is to concatenate all values in single row to one string
for count1 = 1:row
for count2 = 1:column
finalStringtoDisplay = [finalStringtoDisplay,' ',Sa_C_temp{count1,count2}];
end
finalStringtoDisplay = sprintf ('% s \n',finalStringtoDisplay);
end
%msgbox (finalStringtoDisplay,'Sa'); % to diplay the message box.
%-----Aceleraciones y desplazamintos max--------------
tabla_ace_desp=[];
M_Sa=Sa; %Sa desde el modo 1 hasta los que que existan.
M_Sag=Sa*9.81;%Sag desde el modo 1 hasta los que que existan.
w=sol_frec;
M_Sd_c = cell(NP,2);
for f=1:NP
M_Sd(f,1)= M_Sag(f,1)/ ( w(f,1) )^2 ; % Sd desde el modo 1 hasta los que que existan.
M_Sd_c (f, :) = [ num2cell(M_Sd(f,1)) , ['Mod',num2str(f)] ] ;
end
tabla_ace_desp= [M_Sa,M_Sag,w,M_Sd]; % Tabla con : Cada fila es del modo 1 en adelante, 1º columna: Sa / 2º columna: Sa afctado por g / 3º columna: frecuencias naturrales "w" / 4º columna: Sd
%*******Mostrar M_Sd en Msgbox******************
% now as you know this matrix is in cell format so can not be display in msgbox
% so we need to convert it into string or char format, as follows..
[row, column] = size (M_Sd_c);
% below logic to find the max length of all digits or strings in matrix
maxLength = 0;
for count1 = 1:row
for count2 = 1:column
maxLength = max (length (num2str (M_Sd_c {count1,count2})),maxLength);
end
end
% below logic to make all values or string to be of same length, so I am adding spaces.
for count1 = 1:row
for count2 = 1:column
if maxLength == length (num2str (M_Sd_c{count1,count2}))
M_Sd_c_temp {count1,count2} = num2str (M_Sd_c{count1,count2});
else
diff2 = maxLength - length (num2str (M_Sd_c{count1,count2}));
M_Sd_c_temp {count1,count2} = num2str (M_Sd_c{count1,count2});
for i=1:diff2
M_Sd_c_temp {count1,count2} = [' ',M_Sd_c_temp{count1,count2}];
end
end
end
end
[row, column] = size (M_Sd_c_temp);
finalStringtoDisplay = '';
% below logic is to concatenate all values in single row to one string
for count1 = 1:row
for count2 = 1:column
finalStringtoDisplay = [finalStringtoDisplay,' ',M_Sd_c_temp{count1,count2}];
end
finalStringtoDisplay = sprintf ('% s \n',finalStringtoDisplay);
end
%msgbox (finalStringtoDisplay,'Sd.E.D.D(m)'); % to diplay the message box.
%-----Aceleraciones, desplazamintos max y giros --------------
Zi= zeros(1,NP);
Zi_c = cell(2,NP);
menospiso =0;
Coe_par=Coe_par; %--->COE DE PART MODAL (R): DEL PASO 6. Del el modo mas Bajo al mas Alto.
Modos_C=Modos_C;
Yp = zeros(NP,NP+1);
Yp_c= cell(NP+1,NP+1);
NodosT1= sortrows(unique(NodosT(:,2)),'descend');
NodosT= sortrows(NodosT,2,'descend');
%--->Despla Max y Despla translacionales
for f=1:NP
[Pos_GL_Y1] = find( NodosT (:,2) == NodosT1(f,1) );
[Minx_piso,Pminx]= min( NodosT( Pos_GL_Y1,1 ) );
Zi (:,f) = abs( Coe_par(f,1) )* M_Sd(f,1); % desplazamientos
Zi_c (:, f) = [ num2cell( Zi (:,f) ) ; ['Mod',num2str(f)] ] ;
Yp(1:NP, f)= Modos (:,f)*Zi(1,f);
Yp(f, 4)= NodosT ( Pos_GL_Y1 (Pminx,1) , 3 );
Yp_c (:, f) = [ num2cell(Yp(1:NP, f)) ; ['Mod',num2str(f)] ] ;
Yp_c {f, NP+1} = ['U ',num2str( NodosT ( Pos_GL_Y1 (Pminx,1) , 3 ) )] ;
menospiso=menospiso+1; % BORRAR
end
%*******Mostrar Yp_c en Msgbox******************
% now as you know this matrix is in cell format so can not be display in msgbox
% so we need to convert it into string or char format, as follows..
[row, column] = size (Yp_c);
% below logic to find the max length of all digits or strings in matrix
maxLength = 0;
for count1 = 1:row
for count2 = 1:column
maxLength = max (length (num2str (Yp_c {count1,count2})),maxLength);
end
end
% below logic to make all values or string to be of same length, so I am adding spaces.
for count1 = 1:row
for count2 = 1:column
if maxLength == length (num2str (Yp_c {count1,count2}))
Yp_c_temp {count1,count2} = num2str (Yp_c {count1,count2});
else
diff3 = maxLength - length (num2str (Yp_c {count1,count2}));
Yp_c_temp {count1,count2} = num2str (Yp_c {count1,count2});
for i=1:diff3
Yp_c_temp {count1,count2} = [' ',Yp_c_temp{count1,count2}];
end
end
end
end
[row, column] = size (Yp_c_temp);
finalStringtoDisplay = '';
% below logic is to concatenate all values in single row to one string
for count1 = 1:row
for count2 = 1:column
finalStringtoDisplay = [finalStringtoDisplay,' ',Yp_c_temp{count1,count2}];
end
finalStringtoDisplay = sprintf ('% s \n',finalStringtoDisplay);
end
%msgbox (finalStringtoDisplay,'Yp-tras (m)'); % to diplay the message box.
%------------------------->Despla Rotacionales
Ksp_N=zeros( length(NFKsp)+1,length(NCKsp)+1 ) ;
Kss_N=zeros( length(NCKss)+1,length(NCKss)+1 ) ;
Ksp_N(length(NFKsp)+1,1:length(NCKsp))= NCKsp;
Ksp_N( 1 : length(NFKsp) , length(NCKsp)+1 )= NFKsp;
Ksp_N( 1 : length(NFKsp) , 1:length(NCKsp) ) = Ksp_N( 1 : length(NFKsp) , 1:length(NCKsp) ) + Ksp;
Kss_N(length(NFKss)+1,1:length(NCKss))= NCKss;
Kss_N( 1:length(NFKss) , length(NCKss)+1 )= NFKss;
Kss_N( 1:length(NFKss) , 1:length(NCKss) ) = Kss_N( 1 : length(NFKsp) , 1:length(NFKss) ) + Kss;
[m_Ys,n_Ys]=size(inv(Kss)*Ksp);
Ys=zeros(m_Ys,NP+1);
Ys_c= cell(m_Ys+1,NP+1);
menospiso=0;
for f=1:NP
Ys(:,f)= -inv(Kss)*Ksp*Yp(:,f);
Ys_c (:, f) = [ num2cell(Ys(:,f)) ; ['Mod',num2str(f)] ] ;
end
for f=1:m_Ys
Ys(f,4)= NFKsp(f,1) ;
end
for f=1:length(NFKsp)
Ys_c {f, NP+1} = ['T',num2str(NFKsp(f,1))] ;
end
%*******Mostrar Ys_c en Msgbox******************
% now as you know this matrix is in cell format so can not be display in msgbox
% so we need to convert it into string or char format, as follows..
[row, column] = size (Ys_c);
% below logic to find the max length of all digits or strings in matrix
maxLength = 0;
for count1 = 1:row
for count2 = 1:column
maxLength = max (length (num2str (Ys_c {count1,count2})),maxLength);
end
end
% below logic to make all values or string to be of same length, so I am adding spaces.
for count1 = 1:row
for count2 = 1:column
if maxLength == length (num2str (Ys_c {count1,count2}))
Ys_c_temp {count1,count2} = num2str (Ys_c {count1,count2});
else
diff4 = maxLength - length (num2str (Ys_c {count1,count2}));
Ys_c_temp {count1,count2} = num2str (Ys_c {count1,count2});
for i=1:diff4
Ys_c_temp {count1,count2} = [' ',Ys_c_temp{count1,count2}];
end
end
end
end
[row, column] = size (Ys_c_temp);
finalStringtoDisplay = '';
% below logic is to concatenate all values in single row to one string
for count1 = 1:row
for count2 = 1:column
finalStringtoDisplay = [finalStringtoDisplay,' ',Ys_c_temp{count1,count2}];
end
finalStringtoDisplay = sprintf ('% s \n',finalStringtoDisplay);
end
h = msgbox (finalStringtoDisplay,'Ys-rot (Rad)'); % to diplay the message box.
set(h, 'position', [100 300 500 200]); %makes box bigger
set (h, 'Resize' , 'on' );
%-----Buscando nodos Y fomando vector de desplaz --------------
MRT=MRT;
NodosT=NodosT;
NodosT1= sortrows(unique(NodosT(:,2)),'descend');
NodosT= sortrows(NodosT,2,'descend');
[X,Y] = ismember(NodosT1,NodosT (:,2));
Despl_T= [ Yp_c ; Ys_c ] ;
Despl_T2= [ Yp ; Ys ] ; % AGREGAR!!
[Fyp,Cyp]=size(Yp);
[FxNT,FyNT]=size(NodosT);
Num_nodos = ( NodosT ( 1:FxNT , 2 ) )' ;
X = diff(Num_nodos)~=0;
B = find([true,X]);
E = find([X,true]);
C= [B;E]; %C tiene tantas columnas como pisos.
BBC=zeros(NP,1);
for f=1:NP
MatrizNodosPiso = NodosT ( C(:,f), : )
[AA,BB]= ismember ( MatrizNodosPiso (:,3) , Despl_T2 (1:Fyp,4) ); % ismember(B,A); %Donde estan los elementos de B dentro de A (A grande)
[AA1,BB1]= ismember ( Despl_T2 (1:Fyp,4) , MatrizNodosPiso (:,3) );
NumNodos=sum(BB(:)==0);
PosCeros = find(BB == 0);
PosUno =find(BB1 ~= 0);
for j=1:NumNodos
Agregarfila=Despl_T2(PosUno,1:3); % Fila a copiar
Agregarfila=[Agregarfila MatrizNodosPiso( PosCeros ( j , 1 ) , 3 ) ];
Despl_T2 = [Despl_T2(1:PosUno+1-1, :); Agregarfila ; Despl_T2(PosUno+1:end, :)]
Fyp=Fyp+1;
end
end
Nodos_cim=Nodos_cim;
for j=1:length (Nodos_cim)
[Fdes,Cdes]=size(Despl_T2);
Agregarfila = [0 0 0 Nodos_cim(j,1)];
Despl_T2 = [Despl_T2(1:Fdes*0.5-1, :); Agregarfila ; Despl_T2(Fdes*0.5:end, :)];
Despl_T2 = [Despl_T2; Agregarfila];
end
%-----FUERZAS INTERNAS --------------
[Fdes,Cdes]=size(Despl_T2);
Vec_despla=zeros(6,1);
i=1;
matriz_fuerzas_c=cell(7,2);
for j=1:NP
for f=1:VarElem_F
AA_U= ismember ( Despl_T2 (1:Fdes*0.5,4) , MRT (f*7,1:3) ); % Posiciones de Nodo inicial en Despl_T2 (U)
BB_U= ismember ( Despl_T2 (1:Fdes*0.5,4) , MRT (f*7,4:6) ); % Posiciones de Nodo final en Despl_T2 (U)
AA_T= ismember ( Despl_T2 (Fdes*0.5+1:Fdes,4) , MRT (f*7,1:3) ); % Posiciones de Nodo inicial en Despl_T2 (T)
BB_T= ismember ( Despl_T2 (Fdes*0.5+1:Fdes,4) , MRT (f*7,4:6) ); % Posiciones de Nodo final en Despl_T2 (T)
AA_U= find(AA_U == 1);
BB_U= find(BB_U == 1);
AA_T= find(AA_T == 1)+Fdes*0.5 ;
BB_T= find(BB_T == 1)+Fdes*0.5 ;
if ( sum(AA_U(:)~=0) && sum(BB_U(:)~=0) )
Vec_despla(1,1)=Despl_T2 (AA_U,j);
Vec_despla(2,1)=0;
Vec_despla(3,1)=Despl_T2 (AA_T,j);
Vec_despla(4,1)=Despl_T2 (BB_U,j);
Vec_despla(5,1)=0;
Vec_despla(6,1)=Despl_T2 (BB_T,j);
matriz_fuerzas= MRT (i:i+5,1:6) * Vec_despla;
matriz_fuerzas_c {1, 1} = matriz_fuerzas (1,1) ;
matriz_fuerzas_c {2, 1} = matriz_fuerzas (2,1) ;
matriz_fuerzas_c {3, 1} = matriz_fuerzas (3,1) ;
matriz_fuerzas_c {4, 1} = matriz_fuerzas (4,1) ;
matriz_fuerzas_c {5, 1} = matriz_fuerzas (5,1) ;
matriz_fuerzas_c {6, 1} = matriz_fuerzas (6,1) ;
matriz_fuerzas_c {7, 1} = ['Mod ', num2str( j ) ];
matriz_fuerzas_c {1, 2} = ['Fx', num2str( Despl_T2(AA_U,NP+1) ) ] ;
matriz_fuerzas_c {2, 2} = ['Fy', num2str( Despl_T2(AA_U,NP+1) ) ] ;
matriz_fuerzas_c {3, 2} = ['M', num2str( Despl_T2(AA_U,NP+1) ) ] ;
matriz_fuerzas_c {4, 2} = ['Fx', num2str( Despl_T2(BB_U,NP+1) ) ] ;
matriz_fuerzas_c {5, 2} = ['Fy', num2str( Despl_T2(BB_U,NP+1) ) ] ;
matriz_fuerzas_c {6, 2} = ['M', num2str( Despl_T2(BB_U,NP+1) ) ] ;
matriz_fuerzas_c {7, 2} = ['Mod ', num2str( j ) ];
%*******Mostrar FUERZAS INT en Msgbox******************
% now as you know this matrix is in cell format so can not be display in msgbox
% so we need to convert it into string or char format, as follows..
[row, column] = size (matriz_fuerzas_c);
% below logic to find the max length of all digits or strings in matrix
maxLength = 0;
for count1 = 1:row
for count2 = 1:column
maxLength = max (length (num2str (matriz_fuerzas_c {count1,count2})),maxLength);
end
end
% below logic to make all values or string to be of same length, so I am adding spaces.
for count1 = 1:row
for count2 = 1:column
if maxLength == length (num2str (matriz_fuerzas_c {count1,count2}))
matriz_fuerzas_c_temp {count1,count2} = num2str (matriz_fuerzas_c {count1,count2});
else
diff4 = maxLength - length (num2str (matriz_fuerzas_c {count1,count2}));
matriz_fuerzas_c_temp {count1,count2} = num2str (matriz_fuerzas_c {count1,count2});
for i=1:diff4
matriz_fuerzas_c_temp {count1,count2} = [' ',matriz_fuerzas_c_temp{count1,count2}];
end
end
end
end
[row, column] = size (matriz_fuerzas_c_temp);
finalStringtoDisplay = '';
% below logic is to concatenate all values in single row to one string
for count1 = 1:row
for count2 = 1:column
finalStringtoDisplay = [finalStringtoDisplay,' ',matriz_fuerzas_c_temp{count1,count2}];
end
finalStringtoDisplay = sprintf ('% s \n',finalStringtoDisplay);
end
h = msgbox (finalStringtoDisplay,'Fuerzas (N) y Mom (N*m)') ; % to diplay the message box.
set(h, 'position', [100 300 250 200]); %makes box bigger
set (h, 'Resize' , 'on' ) ;
waitfor(h);
i=i+7;
end
end
end
XXX=1;
% --- Executes when entered data in editable cell(s) in TablaMasa.
function TablaMasa_CellEditCallback(hObject, eventdata, handles)
% hObject handle to TablaMasa (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% Indices: row and column indices of the cell(s) edited
% PreviousData: previous data for the cell(s) edited
% EditData: string(s) entered by the user
% NewData: EditData or its converted form set on the Data property. Empty if Data was not changed
% Error: error string when failed to convert EditData to appropriate value for Data
% handles structure with handles and user data (see GUIDATA)
% num_elem=cell(NP,2);
% num_elem(:,:)={''};
% set(handles.TablaMasa,'Data',num_elem);
% MasaDig(1,2) = str2double(eventdata.EditData) ;
% set(handles.TablaMasa,'Data', MasaDig);
% --- Outputs from this function are returned to the command line.
function varargout = form2_OutputFcn(~, ~, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function Fv_Label_Callback(hObject, eventdata, handles)
% hObject handle to Fv_Label (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Fv_Label as text
% str2double(get(hObject,'String')) returns contents of Fv_Label as a double
% --- Executes during object creation, after setting all properties.
function Fv_Label_CreateFcn(hObject, eventdata, handles)
% hObject handle to Fv_Label (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Fa_Label_Callback(hObject, eventdata, handles)
% hObject handle to Fa_Label (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Fa_Label as text
% str2double(get(hObject,'String')) returns contents of Fa_Label as a double
% --- Executes during object creation, after setting all properties.
function Fa_Label_CreateFcn(hObject, eventdata, handles)
% hObject handle to Fa_Label (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Aa_Label_Callback(hObject, eventdata, handles)
% hObject handle to Aa_Label (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Aa_Label as text
% str2double(get(hObject,'String')) returns contents of Aa_Label as a double
% --- Executes during object creation, after setting all properties.
function Aa_Label_CreateFcn(hObject, eventdata, handles)
% hObject handle to Aa_Label (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Av_Label_Callback(hObject, eventdata, handles)
% hObject handle to Av_Label (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Av_Label as text
% str2double(get(hObject,'String')) returns contents of Av_Label as a double
% --- Executes during object creation, after setting all properties.
function Av_Label_CreateFcn(hObject, eventdata, handles)
% hObject handle to Av_Label (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function I_Label_Callback(hObject, eventdata, handles)
% hObject handle to I_Label (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of I_Label as text
% str2double(get(hObject,'String')) returns contents of I_Label as a double
% --- Executes during object creation, after setting all properties.
function I_Label_CreateFcn(hObject, eventdata, handles)
% hObject handle to I_Label (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
function TablaMasa_CreateFcn(hObject, eventdata, handles)
% hObject handle to TablaMasa (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
function Can_port_label_Callback(hObject, eventdata, handles)
% hObject handle to Can_port_label (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Can_port_label as text
% str2double(get(hObject,'String')) returns contents of Can_port_label as a double
% --- Executes during object creation, after setting all properties.
function Can_port_label_CreateFcn(hObject, eventdata, handles)
% hObject handle to Can_port_label (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

サインイン to comment.

製品


リリース

R2017b

1 件の回答

Walter Roberson
回答者: Walter Roberson
2019 年 7 月 24 日

Absolutely nothing about the Symbolic Toolbox can be compiled.
The work-around (which is not always good enough) is to do the calculations in symbolic form ahead of time and generate matlab code from the result, such as using matlabFunction() with the 'file' option.
matriz_fuerzas_c {1, 2} = ['Fx', num2str( Despl_T2(AA_U,NP+1) ) ] ;
That block of code looks suspicious to me. I suspect you are trying to use numbered variables -- which would fit in with your earlier use of eval() .
maxLength = max (length (num2str (matriz_fuerzas_c {count1,count2})),maxLength);
Sure enough: num2str() applied to a character vector that contains a variable name, is equivalent to eval() of the variable name. You have only gotten rid of the eval() on the surface.

  11 件のコメント

Walter Roberson
2019 年 7 月 26 日
Your line
['Fx', num2str( Despl_T2(AA_U,NP+1) )]
implies that you have a series of numbered Fx variables, Fx1, Fx2, and so on. You should store all of those in a cell array
Fx_cell = {Fx1, Fx2, Fx3, ....};
Do not attempt to generate those entries in a loop: if you do not know the number of them ahead of time then you should not be generating the variable names dynamically.
Pedro Guevara 2019 年 7 月 26 日
Hi. Look, I don't think that the dynamic name variable is the cause of the problem, since I just put that same programming in my Guide 1 (the one I did compile) and when compiling it works perfectly, showing the msgbox without any problem. (Attached I send you the new files with the aforementioned modification for you to check, it is from line 693 to 755)
I wanted to see what the problem might be and I was given to put msxbog of the variables that receive the information from Guide 1 "Form1" to Guide 2 "Form2" (with the purpose of showing the variables and knowing if guide 2 was receiving the information), and when compiling does not open the "form2". It will not be possible that the whole problem is occurring by passing variables from form1 to form2?
Would it be too much trouble if I ask you to help me review this part? thank you
Walter Roberson
2019 年 7 月 26 日
I am not willing to debug the use of dynamic variable names.

サインイン to comment.



Translated by