1
$\begingroup$

I have the following Mathematica Code.

QueProcess = QueueingProcess[\[Lambda], \[Mu], c, c];
Simplify[QueueProperties[QueProcess], c > 0 && c \[Element] Integers];
NumReq = RandomFunction[QueProcess /. {\[Lambda] -> 1, \[Mu] -> 2, c -> 10}, {0, 9999, 
    1}];
Val = NumReq["Values"];

Note that Val contains 10000 elements.

Now I want to generate a matrix of size 100 X 10000. That is I want to run the following

NumReq = RandomFunction[QueProcess /. {\[Lambda] -> 1, \[Mu] -> 2, c -> 10}, {0, 9999, 
        1}];
Val = NumReq["Values"];

100 times and save the values of each realization as a row in the matrix.

Finally, I need to export to matrix as .mat format to use it in Matlab.

Any suggestions!

$\endgroup$
0
$\begingroup$

Just use Table with an index for Val (I changed 9999 to 99 to make things faster):

 Table[NumReq = 
  RandomFunction[
   QueProcess /. {λ -> 1, μ -> 2, c -> 10}, {0, 99, 1}];
 Val[k] = NumReq["Values"], {k, 1, 100}]

Then Use Table again to get the Val Matrix as an assembly of Rows.

Valmat = Table[Val[k], {k, 1, 100}]

You get the Expected dimensions for Valmat

In[15]:= Dimensions[Valmat]

Out[15]= {100, 100}

Export should work also:

Export["valmat.mat", Valmat]

(I did not check the contents of valmat.mat in Matlab though)

Hope this helps !

$\endgroup$
  • $\begingroup$ Unfortunately, it is not working for me! When I find the dimension , it just gives {100} and gives an error message "Export::type: {{0,0,0,0,0,0,0,1,1,0,1,1,1,1,3,0,0,0,0,0,0,1,1,0,0,0,0,0,0,2,1,1,1,1,0,0,0,2,0,0,0,0,0,0,1,0,0,0,0,0,<<9951>>}[1],{0,0,0,0,0,0,0,1,1,0,1,1,1,1,3,0,0,0,0,0,0,1,1,0,0,0,0,0,0,2,1,1,1,1,0,0,0,2,0,0,0,0,0,0,1,0,0,0,0,0,<<9951>>}[2],<<48>>,<<50>>} cannot be exported to the MAT format." $\endgroup$ – George Farnandez Oct 4 '17 at 7:07
  • $\begingroup$ I think the second statement is not needed. I mean "Valmat = Table[Val[k], {k, 1, 100}]" is not required. $\endgroup$ – George Farnandez Oct 4 '17 at 7:17
  • $\begingroup$ The code works fine for me without any errors. Which Mathematica version are you on ? Can you try quitting kernel and then running the code again ? $\endgroup$ – Lotus Oct 4 '17 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.