- create a vector of x values from -2 to 5.
- create a corresponding vector of y values by evaluating the function.
- plot y as a function of x.
- maybe pretty up the graph a bit.
how to write a function in interval?
조회 수: 46(최근 30일)
Matt Tearle 2014년 10월 21일
MATLAB Academy can help you learn the basics of MATLAB. Also the Getting Started section of the doc, as Jose-Luis suggested.
For this specific question, you'll need to:
For 2 you'll need to know about array operations. For 4 you can use xlabel, ylabel, title, xlim, ylim, and/or axis.
As Jose-Luis mentioned, if you need the roots exactly, you can use fzero, but that seems a bit advanced for HW#1. Because the function is a polynomial, you could also use polyval (for part 2) and roots. But, again, that seems more than is necessary.