Info

此问题已关闭。 请重新打开它进行编辑或回答。

working with input argument of a function

1 次查看(过去 30 天)
Elia
Elia 2014-1-16
关闭: MATLAB Answer Bot 2021-8-20
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 .

回答(1 个)

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

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by