# How to acces the array element of symbolic array

**URL:** <https://discourse.julialang.org/t/how-to-acces-the-array-element-of-symbolic-array/78135>\
**Category:** General Usage\
**Tags:** question, symbolics\
**Created:** [March 19, 2022, 4:07pm UTC](https://discourse.julialang.org/t/how-to-acces-the-array-element-of-symbolic-array/78135 "2022-03-19T16:07:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![manoj.centura](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manoj.centura/32/216443_2.png) [@manoj.centura](https://discourse.julialang.org/u/manoj.centura)\
**Post date:** [March 19, 2022, 4:07pm UTC](https://discourse.julialang.org/t/how-to-acces-the-array-element-of-symbolic-array/78135/1 "2022-03-19T16:07:56Z")

</div>

Hi All, I want to convert matlab code to julia. is there a way to access elements of symbolic expression.

```matlab
function [xqq,xq,wq]=SetIntoptimal1D(n)

clc
#clear all;
syms y
# Input n: Quad pt rule

m=n-1;
P=sym('a',[1,n]);
P(1)=1;
P(2)=y;

for i=1:m

    P(i+2)=((2.0*i+1)*y*P(i+1)-(i)*P(i))/(i+1.0);
   # P(i)=P(i+1);
   # P(i+1)=P(i+2);
end
if n==1
    P(n)=P(1);
end
p=n-1;
t=p/(p+1);
#Pn=expand(P(n+1));
Pn=expand(P(n+1)-t*P(n-1));
xqq=solve(vpa(Pn,32));
xqq=sort(xqq);
#update here
xq=zeros(n);
parfor i=1:n
 xq(i)=(xqq(i)+1)/2;
end
xq=sort(xq);

for k=1:1:n
    P(1)=1;
    P(2)=y;
    m=n;

for i=1:m

    P(i+2)=((2.0*i+1)*y*P(i+1)-(i)*P(i))/(i+1.0);

end

P1=((n+1)/(1-y*y))*(y*P(n+1)-P(n+2));
P2=((n-1)/(1-y*y))*(y*P(n-1)-P(n));
Pn=P(n)*(P1-t*P2);
#Pn=x*P(n+1)-P(n+2);

   wqq(k)=vpa(2*(p*(1+t)+t)/(p*(p+1))/...
                                   subs(Pn,y,xqq(k)),32);

end

parfor i=1:n
 wq(i)=wqq(i)/2;
end
# disp('Nodes');
# disp(xq);
# disp('Weights')
# disp(wq)
end
Julia code converted so far

using Symbolics
@variables y
# Input n: Quad pt rule

n=10
m=n-1;
 @variables P[1:n]
Symbolics.scalarize(P)
```
