Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem exporting ARRAY values to txt file

Status
Not open for further replies.

Rodrigo Benitez

Civil/Environmental
Oct 9, 2019
14
Hi guys, I'm having some problem with exporting an ARRAY with with 15 values in 1 column to a .txt file in order to copy it to excel. I tried googling but still don't understand the format required, and the warning saying that I can't use the command *VWRITE directly in the GUI. Any help would be very appreciated.

This is my ARRAY in ansys:

image_s2kips.png


This is my code to export it:

/INPUT,sx,txt
*CFOPEN,SX,txt
*VWRITE,sx(1)
(15E20.5)
*CFCLOSE
/OUTPUT,sx,txt

Thanks in advance.
 
Replies continue below

Recommended for you

An alternative is to export it out in market matrix file format maintained by NIST:
Code:
*dmat, exportmatrix, D, import, APDL, c ! export to matrix file
*export, exportmatrix, mmf, mytemp.mtx

You can then read it in Matlab (and Octave?) using mmread.m found here.

After you have the function in your path, reading it into matlab is simply:
Code:
c = mmread('mytemp.mtx');


Best,
Jason
 
Hope this will help:

1. Create input file (extension .inp) with the text copied from the below.
2. You have to select ANSYS Batch in simulation environment tab at ANSYS Product Launcher (in graphical interface exporting to text file does not work, hence batch run required)
3. Select your job file and just created input and click Run button

Let us say your array is named array_sx(i) and is already defined and filled in ANSYS and has 100 inputs
Input content with extension .inp:

finish
resu
/post1
*cfopen,example_name,out
*do,i,1,100
*vwrite,array_sx(i)
(e17.10)
*enddo
/exit,nosave

 
Thanks sk_cheah, but I'm not using Matlab or Octave, I want to use the data in Excel.

Vitkacy1989: Thanks for you help. I'll try that, but isn't there an easier way to export or be able to copy the array results from a list and the paste them into Excel?
 
What do you mean by easier? Here are two different ways to write an array which has 15 rows and 1 column to a file.

The contents of the code have to be in txt file which is run from apdl. The first command mwrite is more general.
It can write an array which has more columns than one to a file.

Code:
!Create array and fill with ramped values
*dim, arr, array, 15,1 
*vfill, arr, ramp, 0, 100.1

*mwrite, arr, arr1, txt
(F16.2)

*cfopen,arr2,txt
*vwrite,arr(1)
(F16.2)
*cfclose

This is an example how to use vwrite command to write multiple columns to file:

Code:
*dim, arr, array, 15,2
*vfill, arr(1,1), ramp, 0, 100.1
*vfill, arr(1,2), ramp, 99, 50.2

*cfopen,arr3,txt
*vwrite,arr(1,1), arr(1,2)
(F10.6,',',F10.6)
*cfclose

You might have to tweak the fortran formatting depending on your case.
 
If you want to use vwrite from gui you can go to Parameters --> Array Parameters --> Write To File.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor