Practical 2: Variables, Script M-files and Graphing
Naming of Numerical Values in MATLAB
Using Variables
Consider the polynomial function to be calculated for various values.
> Type in x^2 + 4x + 3 to set the value of x equal to 3 and then evaluate the value of the polynomial y. Warning: The above code contains an error that is commonly made by learners. > What is the error? > Change the value of x to evaluate the polynomial for x = 5 and 7. You will need to re-run the command to solve the polynomial each time you update x. |
Coding Reminder: The up-arrow on the keyboard will recall a previous line for you to edit. |