Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

working with input argument of a function

1 view (last 30 days)
Elia
Elia on 16 Jan 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
i have table with 2 columns , the input are functions and Time intervals , in which each function must be plotted .
i want to create a variable , that is equal to the end value of the before last function . for example the function f1 ended at the time t_end , this variable should be m=f1(t_end) . in order to be able to use it in the body of the next function ( f2= f1(t_end)+...) if i want .
the problem ist how to get this variable as an input argument , the whole code look like that
MTablecurrentdata=get(handles.Mtable,'data');
Momentdata=MTablecurrentdata(:,1);
Timedata=MTablecurrentdata(:,2);
if size(MTablecurrentdata,1)==1
Mi= str2func(['@(t)' Momentdata{1,1}]);
Ti = str2num(Timedata{1,1});
fplot(Mi,Ti,'Parent',handles.axes1);
else
for i=2:size(MTablecurrentdata,1)
Told = str2num(Timedata{i-1,1}); %old time interval
Tnew = str2num(Timedata{i,1}); %new time interval
%t2 end time of the old function [t1 t2]
Endtime=max(str2num(Timedata{i-1,1}));
%t3 start time of the new function [t3 t4]
Starttime=min(str2num(Timedata{i,1}));
Mfuncold= str2func(['@(t)' Momentdata{i-1,1}]);
Mfuncnew= str2func(['@(t)' Momentdata{i,1}]);
fplot(Mfuncold,Told,'Parent',handles.axes1);
hold(handles.axes1,'on')
fplot(Mfuncnew,Tnew,'Parent',handles.axes1);
hold(handles.axes1,'on')
end
hold(handles.axes1, 'off')
end
the input argument m of the function handles must be equal to Mfuncold(Endtime) i tried many ways , but no result .

Answers (1)

Walter Roberson
Walter Roberson on 16 Jan 2014
  1 Comment
Elia
Elia on 17 Jan 2014
i tried to do it , without a result . can you please show me how the code in my question will look like ?

This question is closed.

Community Treasure Hunt

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

Start Hunting!