Aptech Systems, Inc. Worldwide Headquarters
Aptech Systems, Inc.
2350 East Germann Road, Suite #21
Chandler, AZ 85286
Ready to Get Started?
Request Quote & Product Information
Training & Events
Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.
Have a Specific Question?
Q&A: Register and Login
Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.
Join our community to see why our users are considered some of the most active and helpful in the industry!
Where to Buy
Recent Tagsapplications character vectors CML CMLMT Constrained Optimization datasets dlibrary dllcall econometrics error error codes error handling errors Excel file i/o floating network GAUSS Engine GAUSS Light graphics GUI hotkeys installation Java API license licensing linux loading data loops matrices matrix manipulation Maxlik MaxLikMT Memory multidimensional array optimization Optmum output panel data PQG graphics procs random numbers strings structures threading writing data
Time Series 2.0 MT
Find out more now
Time Series MT 2.1
Find out more now
Make a loop
I would like to use a loop to simplify the belows. Is there anyone to let me know how?
Dividing 6*m*n array into 6 m*n matrices. Then after transposing 6 matrices, save them as xlsx file.
I'd appreciate it.
fac2group1 = arraytomat(fact2Final[1,.,.]);
fac2group2 = arraytomat(fact2Final[2,.,.]);
fac2group3 = arraytomat(fact2Final[3,.,.]);
fac2group4 = arraytomat(fact2Final[4,.,.]);
fac2group5 = arraytomat(fact2Final[5,.,.]);
fac2group6 = arraytomat(fact2Final[6,.,.]);
xlswritem(fact2group1, "fact2group1.xlsx", "a1", 1, "");
xlswritem(fact2group2, "fact2group2.xlsx", "a1", 1, "");
xlswritem(fact2group3, "fact2group3.xlsx", "a1", 1, "");
xlswritem(fact2group4, "fact2group4.xlsx", "a1", 1, "");
xlswritem(fact2group5, "fact2group5.xlsx", "a1", 1, "");
xlswritem(fact2group6, "fact2group6.xlsx", "a1", 1, "");
Here is some code that will do what you ask and will continue to work if you increase the first dimension of the array to more than six.
//get dimensions of 'fact2Final' orders = getOrders(fact2Final); //First element will contain number //of matrices in the 3D array num_mats = orders; for i(1, num_mats, 1); //Add transpose to assignment step fac2_mat = arraytomat(fact2Final[i,.,.])'; file_name = "fac2group" $+ ntos(i) $+ ".xlsx"; xlsWriteM(fac2_mat, file_name, "a1", 1, ""); endfor;
Or if you wanted to condense it a bit, you could make it short like this:
orders = getOrders(fact2Final); for i(1, orders, 1); xlsWriteM(arraytomat(fact2Final[i,.,.])', "fac2group" $+ ntos(i) $+ ".xlsx", "a1", 1, ""); endfor;
Hello. Thanks a lot. But an error came out, saying ntos is undefined symbol.
Oh, yes. ntos is a new convenience function in GAUSS 14. You can replace:
cvtos(ftocv(i, 0, 0));
for versions older than GAUSS 14.