Info

この質問は閉じられています。 編集または回答するには再度開いてください。

working with input argument of a function

2 ビュー (過去 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