-1

I have an expression like this:

x = [40 50];
expression = -2.254443e-02*x^4 + 1.797023e+02*x^3 + -5.364190e+05*x^2 + 7.107614e+08*x + -3.527500e+11;

Now how do I plot this?

plot(x, expression)

Causes errors.

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104

2 Answers2

1

I agree with Trilarion:

x = [40 50];
expression = -2.254443e-02*x.^4 + 1.797023e+02*x.^3 + -5.364190e+05*x.^2 + 7.107614e+08*x + -3.527500e+11;
plot( x, expression )

plot

Works for me.

If I use:

>> expression = -2.254443e-02*x^4 + 1.797023e+02*x^3 + -5.364190e+05*x^2 + 7.107614e+08*x + -3.527500e+11;
   ??? Error using ==> mpower
   Matrix must be square.

Which makes sense, because x is a (row)vector. If you copy paste exactly the above, what do you get?

macduff
  • 4,655
  • 18
  • 29
1

Use ezplot to plot from an expression string:

x = [40 50];
expression = '-2.254443e-02*x^4 + 1.797023e+02*x^3 + -5.364190e+05*x^2 + 7.107614e+08*x + -3.527500e+11';
ezplot(expression, x);

Please note the addition of single quotes around the expression to turn it into a string!

aardvarkk
  • 14,955
  • 7
  • 67
  • 96