Borrar filtros
Borrar filtros

PULSe in Matlab Symbolic

2 visualizaciones (últimos 30 días)
John Miller
John Miller el 7 de Jun. de 2012
Hi,
I have a approximation of a rectangular function:
function current=pulse(t)
if (t-2.5*round(t/2.5-0.5))<=0.2
current=0.001;
else
current=0;
end
end
Then I need t as symbolic:
syms t;
pulse(t);
BUT I get this ERROR:
Conversion to logical from sym is not possible.
Error in ie1 (line 6)
if (t-2.5*round(t/2.5-0.5))<=0.2
Hope somebody can help. Thank you!

Respuestas (1)

Walter Roberson
Walter Roberson el 7 de Jun. de 2012
You will have to construct a piecewise function. See http://www.mathworks.com/help/toolbox/mupad/stdlib/piecewis.html.
Note that the MuPAD piecewise() function does not have a MATLAB interface, so you will need to use evalin(symengine) or feval(symengine) in order to create the object.
  4 comentarios
John Miller
John Miller el 7 de Jun. de 2012
Thank you!
I have another problem: I need a pulse function which I can use in fsolve for lets say f=x1+pulse(x2)=0
Any Idea?
Walter Roberson
Walter Roberson el 7 de Jun. de 2012
pulsefun = matlabFunction(pulse);
fsolve( @(x) x(1) + pulsefun(x(2)), x0 )

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by