1
votes

I'm trying to export a 2D matrix containing nodes coordinates of an Anys mesh (*.node), in Matlab. In this regard, I'm simply using fopen and fprintf commands in Matlab. For example:

========================================

fid = fopen('c:\new_nodes.node', 'wt'); fprintf(fid,'%3d %10.4e %10.4e %19.4e\n',new_nodes'); % new_nodes : my 2D matrix

=======================================

The content of generated file is okay but I cannot read it in Ansys, and when I open this file (e.g., new_nodes.node) in Notepad++ and do "save as", it becomes readable!!! It would be great if you could help me to find out whats the problem the Matlab code and how can I solve this problem... Thanks in advance,

1
What error do you get?Sardar Usama
Using \r instead of \n may help.rahnema1
Could not load FE model!ir0098
rahnema1, unfortunately, it didn't work...ir0098
Try using only 'w' instead of 'wt' in the fopen functionSardar Usama

1 Answers

0
votes

Probably an error in the line brakes.

Open the file as w instead of wt

When you add the t matlab adds a \r after your \n

[edit @ 17:22]

fid = fopen('new_nodes.node', 'wt');
fprintf(fid,'%3d %10.4e %10.4e %19.4e\n',[pi 2.1 exp(1) 2.5]);
fclose(fid);
fid = fopen('new_nodes.node','r');
B = fread(fid,inf,'*uint8');
fclose(fid);

Now B contains 56 values that sum to 2664. What do you get?

If I save it ase new_nodes2.node using notepad++ I get exactly the same values for B.