I meet this error in matlab app design 2021 but when I use this function in editor, it work normal.
Thank you for your help.
Undefined function 'mtimes' for input arguments of type 'function_handle'.
Error in chiadoi (line 6) if((f(a)) * (f(c)) < 0)
this is my function
function [nghiem,solanlap] = chiadoi(f,a,b,saiso)
solanlap = 0;
syms x;
while(1)
c = (a + b)/2;
if((f(a)) * (f(c)) < 0)
b = c;
else
a = c;
end
e = b - a;
if(e < saiso)
c = (a + b)/2;
nghiem = c;
fprintf("\nnghiem = %f",nghiem);
fprintf("\nso lan lap = %d\n",solanlap);
break;
else
solanlap = solanlap + 1;
end
end
end
This is my code in app designer
f=app.nhaphamEditField.Value;
f = str2func(['@(x)',f])
a=app.nhapaEditField.Value;
b=app.nhapbEditField.Value;
saiso=app.nhapsaisoEditField.Value;
g=app.hamlapEditField.Value;
if(app.lapButton.Value)
[nghiem,solanlap] = lap(f,g,a,b,saiso);
elseif(app.chiadoiButton.Value)
[nghiem,solanlap] = chiadoi(f,a,b,saiso);
else
[nghiem,solanlap] = tieptuyen(f,a,b,saiso);
end
app.nghiemEditField.Value=num2str(nghiem);
app.solanlapEditField.Value=num2str(solanlap);
plot(app.UIAxes,f);
I tried replace f(a) with fa and f(c) with fc but it dont work