Hi! Could someone help me solve this error please?
Code in a different workspace:
function fun = Proy(t,x)global tiempoglobal kCa1 = x(1);Cb1 = x(2);Ca2 = x(3);Cb2 = x(4);Cao = 20;fun (1) = 1/tiempo*(Cao - Ca1) - (k*Ca1);fun (2) = -1/tiempo*Cb1 + (k*Ca1);fun(3) = 1/tiempo*(Ca1 - Ca2) - (k*Ca2);fun (4) = 1/tiempo*(Cb1 - Cb2)-(k*Ca2);fun = fun';
Code in my GUI:
global tiempoglobal teglobal Rglobal kcontenido = get(handles.opcion,'Value');switch contenido case 1 k = 0.0157; case 2 k = 0.12; case 3 k = 0.089; case 4 k = 0.35;endtiempo = eval(get(handles.residencia,'String'));xo = [0 0 0 0];if tiempo <= 10tint = [0,100];[t,x] = ode45 (@Proy, tint, xo);elseif tiempo <= 45tint = [0,250];[t,x] = ode45 (@Proy, tint, xo);elsetint = [0,450];[t,x] = ode45 (@Proy, tint, xo);endCa1 = x(:,1);Cb1 = x(:,2);Ca2 = x(:,3);Cb2 = x(:,4);R = get(handles.sitime,'Value');if R == 1 te = eval(get(handles.TE,'String')); Ca1e = x(te,1); set(handles,Ca1,'Value',Ca1e); Cb1e = x(te,2); set(handles,Cb1,'Value',Cb1e); Ca2e = x(te,3); set(handles,Ca2,'Value',Ca2e); Cb2e = x(te,4); set(handles,Cb2,'Value',Cb2e);elseif R == 0 Ca1 = x(:,1); set(handles,Ca1,'Value',Ca1); Cb1 = x(:,2); set(handles,Cb1,'Value',Cb1); Ca2 = x(:,3); set(handles,Ca2,'Value',Ca2); Cb2 = x(:,4); set(handles,Cb2,'Value',Cb2); C = [Ca1 Cb1 Ca2 Cb2]; set(handles,Ctot,'Value',C);end
Error shown:
Error using setConversion to double from struct is not possible.Error in trialproy_>calcular_Callback (line 160) set(handles,Ca1,'Value',Ca1e);Error in gui_mainfcn (line 95) feval(varargin{:});Error in trialproy_ (line 42) gui_mainfcn(gui_State, varargin{:});Error inmatlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)trialproy_('calcular_Callback',hObject,eventdata,guidata(hObject)) Error while evaluating UIControl Callback.
I just want to display the result of my variables (e.g. Ca1e) in a static text. Thanks!
Btw: I tried using String instead of Value and it doesn't work either.
Best Answer