Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
R2008b; piecewise and ezplot

Subject: R2008b; piecewise and ezplot

From: Joerg Buchholz

Date: 22 Jan, 2009 15:07:01

Message: 1 of 2

In R2008b, I define a symbolic piecewise function:

f = evalin (symengine, 'piecewise ([x>=0 and x<=pi, 1], [x>pi and x<2*pi, -1])');

Is there a way to use ezplot to plot this function? The obvious usage does not work:

ezplot (f)
??? Error using ==> inlineeval at 15
Error in inline expression ==> piecewise([x in (pi, 2.*pi), -1], [x in [0, pi], 1])
 Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.

Error in ==> inline.feval at 36
        INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);

Error in ==> ezplotfeval at 54
    z = feval(f,x(1),y(1));

Error in ==> ezplot>ezimplicit at 253
u = ezplotfeval(f,X,Y);

Error in ==> ezplot at 153
    hp = ezimplicit(cax,f{1},vars,labels,args{:});

Error in ==> sym.ezplot at 45
   h = ezplot(char(f));

Unfortunately, matlabFuntion does not work either:

matlabFunction (f)
??? Error: Unbalanced or unexpected parenthesis or bracket.

Error in ==> sym.matlabFunction>makeFhandle at 98
SUBS_Fhandle = eval(['@(' SUBS_xvarnames ')' vectorize(SUBS_body)]);

Error in ==> sym.matlabFunction at 93
    g = makeFhandle(varnames,vectorize(body));

Subject: R2008b; piecewise and ezplot

From: Bryan Weber

Date: 13 Jul, 2014 19:10:11

Message: 2 of 2

I am also having trouble with this. I am evaluating a rather complex function, and the ezplot function would be very nice to have.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us