Message Boards Message Boards


Trying to Plot a variable vector

Posted 3 months ago
6 Replies
1 Total Likes


I am trying to Plot a vector with variables coordinates. I could already manage to plot a arrow between two points but now i want to change them preferable direct in the Plot.

point1 := {0, 0}
point2[r_] := {5, r}     
 Graphics[Arrow[{point1, point2[r]}]], {r, -3, 3}]

I am getting always the error " Tag list is Protected

Hope you can help me.

6 Replies
Posted 3 months ago

I solved it by myself^^. The Problem is that you cannot put a variable in a vector but you can always multible a variable with a vector. The solution looks like:

point1 = {0, 0}
point2[r_] = {5, 0} + r*{0, 1}
Manipulate[Graphics[Arrow[{point1, point2[r]}]], {r, 0, 3}]
Posted 3 months ago

Wow. I will have to remember that.

Posted 3 months ago


What version of Mathematica are you using? I'm using 12.1 and the code you posted works for me.

That said, I did a little experiment and noticed that if I have r already defined, I do get the error you get. So, I suggest restarting your kernel and see if that "fixes" it.

I'm just learning the Manipulate function, but one thing I have noticed (at least for me) is that I have to watch for symbol name conflicts. That said, I do not see what the issue is with the code you have.

I have to jump on some conference calls. If no one else finds a solution before I can get back to this, I will experiment some more this afternoon.

Thank you for the great question.

Posted 3 months ago

Hi Mike,

Thanks for your response.

...You are right. I used the the command


but it seems that this one doesn't work. So i tried it with


and it worked.

Thank you.

Posted 3 months ago

You could also use this:


It clears all previous definitions. In your case not only r but also point1 and point2.

Note the backtick ` after Global .

What about this?

 Function[{a, b, c}, 
   Graphics3D[Arrow[{{0, 0, 0}, {a, b, c}}], 
    PlotRange -> {{0, 3}, {0, 3}, {0, 3}}]][x, y, z],
 {x, 0, 3}, {y, 0, 3}, {z, 0, 3}]
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract