Got Questions? Get Answers.
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

Thread Subject:
R2008b; piecewise and ezplot

Subject: R2008b; piecewise and ezplot

From: Joerg Buchholz

Date: 22 Jan, 2009 15:07:01

Message: 1 of 1

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));

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