To create a 1x100 vector of x values according to -15<x<0, we can use the linspace function or the colon operator. Here's an example using the colon operator:
main.m20 chars2 lines
This creates a 1x100 evenly spaced vector of x values starting from -15 and going up to 0.
To create 3 more 1x100 vectors using elementwise operators, we can use the +, -, *, and / operators to perform elementwise addition, subtraction, multiplication, and division. For example:
main.m64 chars4 lines
The first line uses elementwise multiplication of sin(x) and cos(x) to create a new vector y1. The second line uses elementwise addition of exp(x) and 2*cos(x) to create a new vector y2. The third line uses elementwise division and exponentiation to create a new vector y3.
By using vectorization and elementwise operators, we can create these 4 vectors efficiently in a single programmatic step.
gistlibby LogSnag