Error: indexing must appear last in an index expression.
Show older comments
i got the following error when i tried to run the code I wrote
Error using str2func
Error: ()-indexing must appear last in an index expression.
Error in Spro>VbR_button_Callback (line 836)
V=str2func(['@(t)
',char(diff(sym(regexprep(char(XFunction_current),'^@\(t\)',''))))]);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in Spro (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)Spro('VbR_button_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Note: In my code the variable x is equal to the end value of the before last function I enter in .The new function I give or enter in the uitable can be depending on x ,but it should have just one input argument t , so i created x , so when I give x it will be as a number and not variable .
Tabledata=get(handles.Xtable,'data');
Positiondata=XTableCurrentdata(:,1); % matrix of Strings (functions)
Timedata=XTableCurrentdata(:,2); %Matrix of Time intervals
n=size(Tabledata,1);
for i=1:n
Tcurrent = str2num(Timedata{i,1}); %t2 end time of the current function [t1 t2]
EndTime_current=max(Tcurrent);
Xfunc_current= str2func(['@(t,x)' Positiondata{i,1}]);
X(1)=0;
X(i+1)=Xfunc_current(EndTime_current,X(i));
XFunction_current=@(t) Xfunc_current(t,X(i));
V=str2func(['@(t) ',char(diff(sym(regexprep(char(XFunction_current),'^@\
(t\)',''))))]);
...
2 Comments
Amit
on 27 Jan 2014
I am sorry Sam. My answer was wrong and very wrong. Thats why I deleted it. Your code is right upto the first str2func. The issue is in second str2fun. I donot know much of symbolic toolbox but there will be many here who can help you.
per isakson
on 27 Jan 2014
Accepted Answer
More Answers (0)
Categories
Find more on Operations on Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!