Message Boards Message Boards

Trying to Plot a variable vector

Posted 4 years ago

Hi,

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}     
Manipulate[
 Graphics[Arrow[{point1, point2[r]}]], {r, -3, 3}]

I am getting always the error " Tag list is Protected

Hope you can help me.

POSTED BY: Timo Rausch
6 Replies

What about this?

Manipulate[
 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}]
POSTED BY: Hans Dolhaine
Posted 4 years ago

You could also use this:

Remove["Global`*"]

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

Note the backtick ` after Global .

POSTED BY: Hans Milton
Posted 4 years ago

Hi Mike,

Thanks for your response.

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

ClearAll

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

Clear[r]

and it worked.

Thank you.

POSTED BY: Timo Rausch
Posted 4 years ago

Wow. I will have to remember that.

POSTED BY: Mike Besso
Posted 4 years ago

Timo:

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 BY: Mike Besso
Posted 4 years 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 BY: Timo Rausch
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract