Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

working with input argument of a function

3 visualizaciones (últimos 30 días)
Elia
Elia el 16 de En. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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 .

Respuestas (1)

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

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by