Beginner: Can help with my code? it seems it does not work, and I always get an error.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I want the user to input P(x) and Q(x) to complete the equation and then solve it. Also it always says Undefined function or variable 'x' and sometimes it says int is not defined but when I add 'syms x' it still tells me an error of:
Warning: Support of character vectors that are not valid variable names or define a number will be removed in a future release. To create symbolic expressions, first create symbolic variables and then use operations on them. > In sym>convertExpression (line 1586) In sym>convertChar (line 1491) In sym>tomupad (line 1243) In sym (line 199) In sym/int (line 63) In co1>Solve_Callback (line 115) In gui_mainfcn (line 95) In co1 (line 42) In matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)co1('Solve_Callback',hObject,eventdata,guidata(hObject)) Error using symengine Unexpected 'identifier'.
if true
function Solve_Callback(hObject, eventdata, handles)
% hObject handle to Solve (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
syms x
p=get(handles.inputEq,'string');
q=get(handles.inputEq2,'string');
l = exp(int(p,x));
left = y*l;
right = q*l;
intright = int(right,x);
set(handles.text5,'string', left);
set(handles.text6,'string',intright);
end
1 Commento
Jan
il 10 Dic 2017
Instead of posting "it says ..." or even worse "sometimes it says", post a copy of the complete error message. Explain, what inputEq and inputEq2 contain as strings. The less details teh readers must guess, the easier and more reliable is can answer be.
Risposte (1)
Karan Gill
il 11 Dic 2017
Modificato: Karan Gill
il 11 Dic 2017
It looks like p and q and maybe other inputs are text inputs. Symbolic functions need symbolic input. Use str2sym: https://www.mathworks.com/help/symbolic/str2sym.html.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!