cant get object's method to return multiple outputs
Mostrar comentarios más antiguos
Hi, i cant get my method to return multiple outputs.
I have my object folder with the classdef
classdef crm < handle
%...
methods (Access = public)
[Tout,Yout]=runTimeDependent(self,n_0,tdata,nedata,Tedata)
end
end
And my function definition in a separate file inside the @crm folder
function [Tout,Yout]=runTimeDependent(self,n_0,tdata,nedata,Tedata)
TSPAN = [tdata(1) tdata(end)];
[Tout,Yout]=ode15s(@odefun,TSPAN,n_0);
function dydt=odefun(t,y)
% ... ode function here
end
end
If i build my object and run the method everything works but if i ask 2 outputs i get an error
c=crm();
% definemy parameters ( Y0, t, ne, Te)
c.runTimeDependent(Y0,t,ne,Te); % This line works
[Tout, Yout] = c.runTimeDependent(Y0,t,ne,Te); %this line throws an error
Only when i ask both my outputs do i get an error
Error using indexing
Too many output arguments.
Error in test_timedep (line 4)
[Tout, Yout] = c.runTimeDependent(Y0,t,ne,Te);
2 comentarios
Walter Roberson
el 28 de En. de 2025
Editada: Walter Roberson
el 28 de En. de 2025
It would be interesting to see the output of
[Tout, Yout] = runTimeDependent(c,Y0,t,ne,Te);
and of
[Tout] = c.runTimeDependent(Y0,t,ne,Te);
vanni meier
el 29 de En. de 2025
Editada: vanni meier
el 29 de En. de 2025
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Construct and Work with Object Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!