Uso de variables en un text edit
Publicado por Lix (4 intervenciones) el 02/07/2013 00:25:47
Hola, estoy realizando un programa en GUI, primero que nada, dicho programa lo realicé de manera simple en un script, pero en el GUI no se como hacer para tomar una función.
Explico, se trata del calculo de las series de Fourier, y en ese programa al introducir la funcion 1 como un numero ejemplo "0" y en la funcion 2 otro , "1" funciona perfectamente, el problema es cuando doy a la función 1 un valor de " 0.1* t ".
este es el error que sale en el workspace
y la verdad no entiendo bien eso jejejeje ñ_ñ
Explico, se trata del calculo de las series de Fourier, y en ese programa al introducir la funcion 1 como un numero ejemplo "0" y en la funcion 2 otro , "1" funciona perfectamente, el problema es cuando doy a la función 1 un valor de " 0.1* t ".
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
syms t
l=str2num(get(handles.edit1,'String'));
f1=get(hObject,'String');
handles.edit2=f1;
guidata(hObject,handles);
f2=get(hObject,'String');
handles.edit2=f2;
guidata(hObject,handles);
a0=1/(2*l)*(int(f2,t,-l,0)+int(f1,t,0,l));
m=50;
for n=1:m
an=1/l*(int(f2*cos(n*pi*t/l),t,-l,0)+ int(f1*cos(n*pi*t/l),t,0,l));
bn=1/l*(int(f2*sin(n*pi*t/l),t,-l,0)+ int(f1*sin(n*pi*t/l),t,0,l));
f(n,:)=an*cos(n*pi*t/l)+bn*sin(n*pi*t/l);
end
g=a0+sum(f)
axes(handles.axes3);
ezplot(g)
xlabel('\bfTIEMPO'); ylabel('\bfm^3/s'); title('\bf SERIE DE FOURIER')
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function pushbutton2_Callback(hObject, eventdata, handles)
syms t
l=str2num(get(handles.edit1,'String'));
f1=get(hObject,'String');
handles.edit2=f1;
guidata(hObject,handles);
f2=get(hObject,'String');
handles.edit2=f2;
guidata(hObject,handles);
a0=1/(2*l)*(int(f2,t,-l,0)+int(f1,t,0,l));
m=50;
for n=1:m
an=1/l*(int(f2*cos(n*pi*t/l),t,-l,0)+ int(f1*cos(n*pi*t/l),t,0,l));
bn=1/l*(int(f2*sin(n*pi*t/l),t,-l,0)+ int(f1*sin(n*pi*t/l),t,0,l));
f(n,:)=an*cos(n*pi*t/l)+bn*sin(n*pi*t/l);
end
g=a0+sum(f)
axes(handles.axes3);
ezplot(g)
xlabel('\bfTIEMPO'); ylabel('\bfm^3/s'); title('\bf SERIE DE FOURIER')
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
este es el error que sale en el workspace
Error using sym>convertExpression (line 2246)
Conversion to 'sym' returned the MuPAD error: Error: Unexpected 'identifier'. [line 1, col 10]
Error in sym>convertChar (line 2157)
s = convertExpression(x);
Error in sym>convertCharWithOption (line 2140)
s = convertChar(x);
Error in sym>tomupad (line 1871)
S = convertCharWithOption(x,a);
Error in sym (line 104)
S.s = tomupad(x,'');
Error in sym/int (line 53)
f = sym(f);
Error in pruebasfinal>pushbutton2_Callback (line 428)
a0=1/(2*l)*(int(f2,t,-l,0)+int(f1,t,0,l));
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in pruebasfinal (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)pruebasfinal('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Conversion to 'sym' returned the MuPAD error: Error: Unexpected 'identifier'. [line 1, col 10]
Error in sym>convertChar (line 2157)
s = convertExpression(x);
Error in sym>convertCharWithOption (line 2140)
s = convertChar(x);
Error in sym>tomupad (line 1871)
S = convertCharWithOption(x,a);
Error in sym (line 104)
S.s = tomupad(x,'');
Error in sym/int (line 53)
f = sym(f);
Error in pruebasfinal>pushbutton2_Callback (line 428)
a0=1/(2*l)*(int(f2,t,-l,0)+int(f1,t,0,l));
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in pruebasfinal (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)pruebasfinal('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
y la verdad no entiendo bien eso jejejeje ñ_ñ
Valora esta pregunta


0