Beginner: Can help with my code? it seems it does not work, and I always get an error.
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Jan
2017 年 12 月 10 日
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.
回答 (1 件)
Karan Gill
2017 年 12 月 11 日
編集済み: Karan Gill
2017 年 12 月 11 日
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!