Hi, I am trying to calculate n(variable) into the formula, but I am only getting the last value. How Can I change that? so i get all the values?
Solved! Go to Solution.
Perhaps I should have included some additional details:
to add the subscript:
To vectorize the function:
Select or highlight the formula you want to vectorize:
Hope this helps.
Some remarks to what was already said:
You defined a range when you typed n:=0,1..4 but you immediately followed the definition by an evaluation (the = at the end to show the result). This is an undocumented trick to convert a range into a vector. Ranges and vectors may look similar but are quite different beasts.
You have n^2 in your formula and n is a vector. Squaring is not defined for vectors and so Mathcad actually could throw an error. Instead Mathcad is designed to perform an implicit vectorization in such cases which means it simply applies the operation on every single element of the vectors. This vector in your formula is now multiplied by a scalar and another scalar is added to every vector element. And now you try to take the root of this vector which again triggers Mathcad's implicit vectorization. So the whole root expression in your formula is a vector. And this vector is multiplied with another vector (n*pi/1000) and vector multiplication IS a well defined operation and the result is a scalar (dot product). If you want the operation to be done element-wise you have to explicitly apply vectorization. How this is done was shown to you by 1aidaho.
On contrary you may note that Luc has NOT used an inline evaluation when he defined the range n. He evaluated it in a separate region. So n in his approach is still a range and can be used what a range is made for - indexing the elements of a vector or matrix. And this is exactly what Luc did. Note that he applied your formula to w[n (n is a vector index here) and not just to w. That way every vector element is calculated one after the other - you may see a range as some kind of implicit loop.
Just thought it might be necessary and helpful to explain in more details the working of the two solutions provided.