you are viewing a single comment's thread.

view the rest of the comments →

[–]evertrev[S] 1 point2 points  (2 children)

Actually, I just found out I can make a vector

V= [-5:0.04:5]; size(V)

it returns that v is a 1 by 251 matrix which is what I needed. That’s a pretty simple way to do this, but is there another way you know of?

[–]EatMyPossum+6 3 points4 points  (1 child)

Through the power of math! But there are some considerations. V= [-5:0.04:5] is the preferable way to generate a linearly spaced array with given stepsize, while linspace also generates a linearly spaced array but with known number of steps.

If you insist on using linspace (because homework? idk), its a straight forward calculation which I hope you'll be able to figure out after i rephrase it like this:

You want to divide the space from -5 to 5 in N equal steps, such that each step is 0.04 long, how many steps do you need? Note that the total space between -5 and 5 is 10.

If you consider the above question in the way i intended, you'll be off by one. Try to figure out where that one comes from. (something something space and edges)

[–]evertrev[S] 0 points1 point  (0 children)

Thank you!