Azzera filtri
Azzera filtri

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 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Steven Lord
Steven Lord il 6 Nov 2017
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.

Più risposte (1)

Walter Roberson
Walter Roberson il 6 Nov 2017
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'.
  1 Commento
Erwin Avendaño
Erwin Avendaño il 6 Nov 2017
Ok, I understand, if I'm sorry it was a double question, I felt desperate to get an answer. So this code is not to make it executable? Okay, how could I make a code for an executable? Could you show me an example of how an executable code is?

Accedi per commentare.

Categorie

Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by