Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.7K Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

export and import list of symbolic variable list.

Posted 9 years ago

Hello,

I am trying to export and import a list of symbolic variable. I want to do that because I don't want to include that part of my code when I am giving it to he people.

Here a simplified version of my code

xhard = {-1, -Sqrt[5/8 + Sqrt[5]/8], 
   1/4 (-1 - Sqrt[5]), -Sqrt[5/8 - Sqrt[5]/8], 1/4 (1 - Sqrt[5]), 0, 
   1/4 (-1 + Sqrt[5]), Sqrt[5/8 - Sqrt[5]/8], 1/4 (1 + Sqrt[5]), Sqrt[
   5/8 + Sqrt[5]/8], 1};
Export["x10.txt", xhard];
xim = Import["x10.txt", "List"];
Dimensions[xim]
Dimensions[xhard]
f = Sin[xs];
fx = SetAccuracy[f /. xs -> xim, 30]
fhard = SetAccuracy[f /. xs -> xhard, 30];
fx - fhard

when I use xim only numerical values are evaluated for fx but values with sqrt seems to translated like a string. I have another list of variables which contains Cos and Sin functions.

How can I export such array and import it back in?

Thank you

Erdem

POSTED BY: Erdem Uguz

Do not use xim = Import["x10.txt", "List"]; to read expressions, use ReadList

SetDirectory[NotebookDirectory[]]
xhard = {-1, -Sqrt[5/8 + Sqrt[5]/8], 
   1/4 (-1 - Sqrt[5]), -Sqrt[5/8 - Sqrt[5]/8], 1/4 (1 - Sqrt[5]), 0, 
   1/4 (-1 + Sqrt[5]), Sqrt[5/8 - Sqrt[5]/8], 1/4 (1 + Sqrt[5]), 
   Sqrt[5/8 + Sqrt[5]/8], 1};
Export["x10.txt", xhard];
xim = ReadList["x10.txt"];
Simplify[xhard - xim]
       {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
POSTED BY: Nasser M. Abbasi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard