Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.9K Views
|
4 Replies
|
1 Total Like
View groups...
Share
Share this post:

Change the variable in the function? (SOLVED)

Posted 9 years ago

part of a bigger code, I am trying to replace the variable in the function by using:

vars = {x, y, z, r, p, l};
varlims = {{1, 2}, {3, 4}, {5, 6}, {7, 8}, {9, 10}, {11, 12}};
poi = {x, y};
svars = {z, r, p, l};
poi[[1]]
u = z Sin[\[Pi] x] + z  Cos[\[Pi] y] + y^6 Cos[2 \[Pi] y];
u /. poi[[1]] -> v1

poi[[1]] is x there I see it but why can't I replace it by v1? I think ./ -> looking for poi[[1]] as a string how can make it to represent x?

POSTED BY: Erdem Uguz
4 Replies
u /. poi[[1]] -> v1;
u /. poi[[2]] -> v2;

this doesn't do anything, I think you meant:

u = u /. poi[[1]] -> v1;
u = u /. poi[[2]] -> v2;
POSTED BY: Sander Huisman
Posted 9 years ago

Kind of yes, I found that I need to rename the u function as

u1 = u /. poi[[1]] -> v1;
u2 = u1 /. poi[[2]] -> v2;

and plot it

psl = Plot3D[u2, {v1, lv1, rv1}, {v2, lv2, rv2}, 
  PerformanceGoal -> "Quality", Mesh -> None, 
  ColorFunction -> Function[{x, y, z}, Hue[z]], ImageSize -> Medium]
POSTED BY: Updating Name
Posted 9 years ago
POSTED BY: Erdem Uguz

Hello, if I run your code I get, as expected

z*Cos[Pi*y] + 
 y^6*Cos[2*Pi*y] + 
 z*Sin[Pi*v1]

So probably there is some assignement to v1 in your code before.

POSTED BY: Rolf Mertig
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard