Skip to main content
14-Alexandrite
July 29, 2024
Solved

Exporting results of matrics to excel file

  • July 29, 2024
  • 2 replies
  • 3015 views

I can't export my results to excel file when the results contains more than one matrics .

I am generating excel files for some results using the function(WRITEXCEL). When the matrics is vector which means has only one colunm it easily export it to excel file. However, when the results has more than one colunm like shown below it doesn't work. this error is on page 33. how can I solve that?

YA_10963798_0-1722266042764.png

 

 

 

 

 

 

It shows error 

YA_10963798_0-1722261927805.pngYA_10963798_1-1722261944219.pngYA_10963798_2-1722261958474.png

 

Best answer by terryhendicott

Hi,

The message has got it right.

it takes time for the excel file data to be written and to then close the excel file.

Because the two statements follow each other and are trying to write to the same file it tries to write the second data before the first is finished.

My system is a very fast computer and fast solid state hard drives so can do the double write to the same file.

 

You can try to swap the order of the two WRITEEXCEL statements so the first is only writing one cell the stride.

If this does not work you could only use one statement and write just the flattened lengths matrix.

 

 

Cheers

Terry

2 replies

Catalina
Community Moderator
July 29, 2024

Hi @YA_10963798,

Thank you for your question!

 

I’d like to recommend to bring more context to your initial inquiry. 
Please refer to this guideline to make your questions more likely to receive a quick and useful answer.

 

Furthermore, please consult this Community Search guideline as well, which boosts up your chances of finding a resolution to your topic(s) much faster. Making use of our Knowledge Base

 

Thank you for your participation and please let me know if you need further assistance! 

 

Best regards,

Catalina | PTC Community Moderator
23-Emerald IV
July 29, 2024

So, you are using Prime 9. Should have mentioned that.

1st error: You cannot have the vertical bar character "|" in a file or path name.

2nd error. The variable is undefined. Make sure it is defined. If A.beta is a function (like you use it in the WRITEEXCEL call), then you must use it as a function in the expression above as well. OR vice versa.

3rd error. Q.CPT is a vector of vectors that is a nested array. WRITEEXCEL accepts only flat arrays. You may need to flatten it first.

 

Success!
L:uc

21-Topaz II
July 30, 2024

Hi,

Here is one way to flatten a nested matrix, Works only if nested matrix is only one level and all nested matrices are the same size like L.inters

Recovering  the data from a flattened matrix file you need to know the stride as well as the data.

Capture.JPG

 

 

Cheers

Terry

 

21-Topaz II
July 30, 2024

Hi,

Noticably faster version of flatten

Capture.JPG