Message Boards Message Boards

0
|
583 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Error SetDelayed::write: Tag Integer is Protected

Posted 2 months ago

Hello everyone. I'm new to Mathematica and I can't understand why I get the error SetDelayed::write: Tag Integer in 1[x,y,z,k] is Protected.

Here's the code. Can someone tell me, what's the problem?

R = 1{x0, y0, z0} = {28, 13, 20}; (*Координаты точки наблюдения*)
kValue = 3; (*Параметр k*)
nValue = 3; (*Верхний предел суммирования для n*)
mValue = 3; (*Верхний предел суммирования для m*)
lValue = 3; (*Верхний предел суммирования для l*)
dValue = 6; (*Параметр d*)


(*Определение функции c*)
c[x_, y_, z_, k_] := ((x - k)/(x - x0))*
  Sqrt[(x - x0)^2 + (y - y0)^2 + (z - z0)^2]

  equation[x_, y_, z_, x0_, y0_, z0_] := P*R^2*Sum[Sum[Sum[P*R^2*1/((x - x0)^2 + (y - y0)^2 + (z -  z0)^2)^(2^(c[x, y, z, kValue]/dValue)), {l, kValue, kValue + nValue}], {m, 1, nValue}], {n, 1, nValue}]

Plot3D[equation[x, y, z, x0, y0, z0], {x, -20, 20}, {y, -20, 20}, 
 PlotRange -> All, AxesLabel -> {"x", "y", "Intensity"}, 
 PlotLabel -> "3D модель"]
Attachments:
POSTED BY: Alex Dark
6 Replies

You must give a value to z to make a plot.

POSTED BY: Gianluca Gorni
Posted 2 months ago

I hope I correctly understood.

I started Mathematica again so that there were no previous definitions

I changed the code to

R = 1;
{x0, y0, z0} = {28, 13, 20}; (*Координаты точки наблюдения*)
kValue = 3; (*Параметр k*)
nValue = 3; (*Верхний предел суммирования для n*)
mValue = 3; (*Верхний предел суммирования для m*)
lValue = 3; (*Верхний предел суммирования для l*)
dValue = 6; (*Параметр d*)
(*Определение функции c*)
c[x_, y_, z_, k_] := ((x - k)/(x - x0))*Sqrt[(x - x0)^2 + (y - y0)^2 + (z - z0)^2]
equation[x_, y_, z_, x0_, y0_, z0_] := P*R^2*Sum[Sum[Sum[P*R^2*1/((x - x0)^2 + (y - y0)^2 + (z -  z0)^2)^(2^(c[x, y, z, kValue]/dValue)), {l, kValue, kValue + nValue}], {m, 1, nValue}], {n, 1, nValue}]
Table[equation[x, y, z, x0, y0, z0], {x, -20, 20,5}, {y, -20, 20,5}]//InputForm

That does not show the error you had so perhaps there was a previous assignment in cache that was causing the problem.

And the Table let me see some of the values that you wanted plotted.

It looks like z and P have not been assigned values. That may explain why there is no plot.

POSTED BY: Bill Nelson
Posted 2 months ago

Yes, I later noticed that the values were not assigned, but in the end this problem was not solved. Should I use the clear function?

POSTED BY: Alex Dark
Posted 2 months ago
SetDelayed::write: Tag Plus in (1/(685+(-10)^2^(1/6))+1/(738+(-10)^2^(1/6)))[x_,y_,z_,x0_,y0_,z0_] is Protected.

There is such a problem, here's an example of code. maybe the amount of iteration is too large?

code

Clear[c, d, P, R]

P = 1;(*Определяем параметры*)
R = 1; (*Коэффициент R*)
{x0, y0, z0} = {28, 13, 20}; (*Координаты точки наблюдения*)
kValue = 1; (*Параметр k*)
{nValue, mValue, lValue} = {10, 10, 
   10}; (*Верхние пределы суммирования*)
dValue = 6; (*Параметр d*)

(*Определение функции c*)
c[x_, y_, z_, k_] := ((x - k)/(x - x0))*
  Sqrt[(x - x0)^2 + (y - y0)^2 + (z - z0)^2]

(*Определение уравнения*)
equation[x_, y_, z_, x0_, y0_, z0_] := 
 P*R^2*Sum[
   1/((x - x0)^2 + (y - y0)^2 + (z - z0)^2)^(2^(c[x, y, z, k]/
         dValue)), {k, 1, nValue}]

(*Построение 3D-графика*)
Plot3D[equation[x, y, z, x0, y0, z0], {x, -20, 20}, {y, -20, 20}, 
 PlotRange -> All, AxesLabel -> {"x", "y", "Intensity"}, 
 PlotLabel -> "3D модель"]
POSTED BY: Alex Dark
Posted 2 months ago

With the code above and a fresh start of Mathematica I get no error and blank plot.

With the code above and a fresh start of Mathematica and z=1 I get no error and a good plot

POSTED BY: Bill Nelson
Posted 2 months ago

image

POSTED BY: Alex Dark
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