if matlab does not signal me any error but in the .exe file does not work how can I write this code in another way?
조회 수: 1 (최근 30일)
이전 댓글 표시
How could I write this code in another way? Do you need the str2double? I put it to get the numerical value
function pushbutton3_Callback(~, ~, handles)
syms x %variable simbolica x
f=get(handles.edit8,'string');
xl=str2double(get(handles.edit3,'string'));
xu=str2double(get(handles.edit5,'string'));
tol=str2double(get(handles.edit4,'string'));
E=100;
xa=100;
i=0;
while(tol<E)
xr=(xl+xu)/2;
fxl=subs(f,x,xl);
fxr=subs(f,x,xr);
m=fxl*fxr;
if(m)<0
xu=xr;
else
xl=xr;
end
E=abs(xr-xa);
xa=xr;
i=i+1;
end
xr;
vpa(E,5)
set(handles.edit6,'string',xr);
set(handles.edit9,'string',E);
% --- Executes on button press in pushbutton4.
댓글 수: 0
채택된 답변
Steven Lord
2017년 11월 6일
You're using functions from Symbolic Math Toolbox (in particular syms, subs, and vpa.) Symbolic Math Toolbox is not eligible for use with MATLAB Compiler.
추가 답변 (1개)
Walter Roberson
2017년 11월 6일
The cause of this is the same as https://www.mathworks.com/matlabcentral/answers/365294-does-my-code-have-an-error#answer_289606 . It even looks to me as if that is a duplicate question . Duplicate questions keep the volunteers spending time cleaning up questions instead of spending time answering the questions.
Not even a tiny bit of the Symbolic Toolbox can be compiled. The program will crash as soon as it encounters 'syms' or 'subs' or 'vpa'.
참고 항목
카테고리
Help Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!