Conversion from mathematica to matlab

• Mathematica
ggeo1
Hello,
i have the following problem in mathematica and i want to convert it in matlab ,but in 3 dimensions.

Code:
npoints = 10000;
vectorpoint := {RandomReal[{-1, 1}], RandomReal[{-1, 1}]}
experiment = Table[vectorpoint, {npoints}];
experiment[[10]]

the result is for example {-0.921607, -0.389386}

Now, in matlab (for 3d)

Code:
npoints = 10000;
v1=2*rand-1;
v2=2*rand-1;
v3=2*rand-1;
vectorpoint=[v1,v2,v3];
experiment=(vectorpoint:npoints);
experiment(10)

The problem is that the result is for example
9.9238 , a one dimension ,but i want 3d.

I can't figure how i must write it.

ggeo1
Hello ,

I tried : experiment([10 10 10]) but it gives me : 8.6808 8.6808 8.6808
But it is supposed to be in the range (-1,1).

Any help?

EDIT----------------------------
Also,how can i do sth like this?

[x y z]=sqrt(1:3)

in order to be x=1 , y=1.4142 , z=1.7321

EDIT------------------------------
For the previous , i did this:

Code:
syms x y z
vec=[x y z]
new=sqrt(1:length(vec))

new=1.0000    1.4142    1.7321   (is there another way to do all this?)

EDIT:::

I also did this :

Code:
vector=[v1,v2,v3]
new=num2cell(vector)
[x,y,z]=new{:}

And finally,

if i name for example ,the previous statement , vector=[x y z]
How can i do this work? ezplot3(vector,'r')

I am new to matlab ( i have done some mathematica though)

Thanks!

Last edited:
ggeo1
Hello,
I updated my code and now i am at this :

Code:
npoints=10000;
vectorpoint=2*rand(1,3)-1
for i=1:npoints
2*rand(1,3)-1
end

1) Is there another way to write this :
for i=1:npoints
2*rand(1,3)-1
end
in an one line?

2) I wrote in the loop 2*rand(1,3)-1 because if i write vectorpoint it will keep only one value of it.Is there a way to write vectorpoint and give me different values every time i call it?

If anyone can help...

ggeo1
Ok, here is the solution

1) Just this : experiment=2*rand(npoints,3)-1

2) As for the vectorpoint,probably only with function