Conversion to matlab.ui.​control.Ed​itField from matlab.ui.Root is not possible.

50 views (last 30 days)
I am trying to write an app for lagrange's multiplier. It shows error in the last line.
please help!
function ButtonPushed(app, event)
syms x y lambda;
f=app.fEditField.Value;
func=str2sym(f(1));
g=app.gEditField.Value;
cons=str2sym(g(1))==0;
L = func + lambda*lhs(cons);
%L=str2sym(l);
dL_dx=diff(L,x)==0;
dL_dy=diff(L,y)==0;
dL_dlambda=diff(L,lambda)==0;
system = [dL_dx; dL_dy; dL_dlambda];
[x_val, y_val,lambda_val] = solve(system, [x y lambda], 'Real', true);
results_numeric = double([x_val, y_val, lambda_val]); % show results in a vector of data type double
[row,col]=size(results_numeric);
max=0;
min=0;
a=0;
x_min=results_numeric(1,1);
x_max=results_numeric(1,1);
y_min=results_numeric(1,2);
y_max=results_numeric(1,2);
max=subs(subs(func,x,results_numeric(1,1)),y,results_numeric(1,2));
min=max;
for i=2:row
a=subs(subs(f,x,results_numeric(i,1)),y,results_numeric(i,2));
if(a>max)
max=a;
x_max=results_numeric(i,1);
y_max=results_numeric(i,2);
elseif(a<min)
min=a;
x_min=results_numeric(i,1);
y_min=results_numeric(i,2);
end
end
% x1=-10:0.1:10;
% y1=x1';
% [X1,Y1]=meshgrid(x1,y1);
% z1 = subs(f, {x, y}, {X1, Y1});
% z2= subs(g, {x, y}, {X1, Y1});
% surf(app.UIAxes,X1,Y1,double(z1));
d=double(max);
app.outputEditField=d; [this is where I get the error.]
error:
The following error occurred converting from matlab.ui.Root to matlab.ui.control.EditField:
Conversion to matlab.ui.control.EditField from matlab.ui.Root is not possible.

Answers (1)

Simon Chan
Simon Chan on 24 Feb 2023
Put it in 'Value' of the EditField object.
app.outputEditField.Value=d

Community Treasure Hunt

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

Start Hunting!