From: Gerrit Grundling on
I use MATLAB 2007 R14. I have two similar text files, both of which contain information about trusses - number of nodes, nodal coordinates, number of truss elements, element connections and constraints, and applied forces.

When I input the one document, using fid=fopen(filename,'r'), everything is fine, but the other one returns fid=-1, i.e. can't open. Why?

This is what the working file contains. It contains data on a two-dimensional truss:

Number_of_nodes
20
Nodal_coordinates
1 0.0 0.0
2 1000.0 0.0
3 2000.0 0.0
4 3000.0 0.0
5 4000.0 0.0
6 5000.0 0.0
7 6000.0 0.0
8 7000.0 0.0
9 8000.0 0.0
10 9000.0 0.0
11 10000.0 0.0
12 1000.0 1500.0
13 2000.0 1500.0
14 3000.0 1500.0
15 4000.0 1500.0
16 5000.0 1500.0
17 6000.0 1500.0
18 7000.0 1500.0
19 8000.0 1500.0
20 9000.0 1500.0
Number_of_elements
39
Element_connectivity
1 1 2 1.0
2 2 3 1.000
3 3 4 1.00
4 4 5 1.0
5 5 6 1.000
6 6 7 1.0
7 7 8 1.0
8 8 9 1.0
9 9 10 1.0
10 10 11 1.000
11 12 13 1.0
12 13 14 1.0
13 14 15 1.0
14 15 16 1.0
15 16 17 1.0
16 17 18 1.0
17 18 19 1.0
18 19 20 1.0
19 2 12 1.0
20 3 13 1.0
21 4 14 1.0
22 5 15 1.0
23 6 16 1.0
24 7 17 1.0
25 8 18 1.0
26 9 19 1.0
27 10 20 1.0
28 1 12 1.0
29 3 12 1.0
30 3 14 1.0
31 5 14 1.0
32 5 16 1.0
33 7 16 1.0
34 7 18 1.0
35 9 18 1.0
36 9 20 1.0
37 11 20 1.0
38 6 15 1.0
39 6 17 1.0
Material_properties
210000
Number_of_prescribed_displacements
3
Prescribed_displacements
1 1 0.0
1 2 0.0
11 2 0.0
Number_of_nodal_loads
3
Nodal_loads
5 2 -100000.0
6 2 -100000.0
7 2 -100000.0


This is the one that doesn't open. It contains data on a three-dimensional truss. The program itself work correctly when I input the matrices directly into the m-file, but it refuses to open the text file with fopen:

Number_of_nodes
4
Nodal_coordinates
1 0.0 0.0 6000.0
2 400.0 0.0 0.0
3 -200.0 346.4 0.0
4 -200.0 346.4 0.0
Number_of_elements
6
Element_connectivity
1 1 2 1.0
2 1 3 1.000
3 1 4 1.00
4 2 3 1.0
5 2 4 1.000
6 3 4 1.0
Material_properties
210000
Number_of_prescribed_displacements
9
Prescribed_displacements
2 1 0.0
2 2 0.0
2 3 0.0
3 1 0.0
3 2 0.0
3 3 0.0
4 1 0.0
4 2 0.0
4 3 0.0
Number_of_nodal_loads
3
Nodal_loads
1 1 -532.33
6 2 -330.0
7 2 -402.85
5 2 -500.0
6 2 -500.0
7 2 -500.0

From: dpb on
Gerrit Grundling wrote:
> I use MATLAB 2007 R14. I have two similar text files, both of which
> contain information about trusses - number of nodes, nodal coordinates,
> number of truss elements, element connections and constraints, and
> applied forces.
>
> When I input the one document, using fid=fopen(filename,'r'), everything
> is fine, but the other one returns fid=-1, i.e. can't open. Why?
....
Impossible to tell from here. Possibilities are the second file isn't
in the working directory, you've misspelled the name, you're working on
a system where file names are case-dependent and have given a wrong case
version of the name, etc., etc., etc., ...

Use the optional form of fopen to return the system error message for
information on what the reason for the failure is...

doc fopen % note optional 'message' return variable

--
From: Wayne King on
"Gerrit Grundling" <totallyplanecrazy(a)gmail.com> wrote in message <ht0m59$4dv$1(a)fred.mathworks.com>...
> I use MATLAB 2007 R14. I have two similar text files, both of which contain information about trusses - number of nodes, nodal coordinates, number of truss elements, element connections and constraints, and applied forces.
>
> When I input the one document, using fid=fopen(filename,'r'), everything is fine, but the other one returns fid=-1, i.e. can't open. Why?
>
> This is what the working file contains. It contains data on a two-dimensional truss:
>
> Number_of_nodes
> 20
> Nodal_coordinates
> 1 0.0 0.0
> 2 1000.0 0.0
> 3 2000.0 0.0
> 4 3000.0 0.0
> 5 4000.0 0.0
> 6 5000.0 0.0
> 7 6000.0 0.0
> 8 7000.0 0.0
> 9 8000.0 0.0
> 10 9000.0 0.0
> 11 10000.0 0.0
> 12 1000.0 1500.0
> 13 2000.0 1500.0
> 14 3000.0 1500.0
> 15 4000.0 1500.0
> 16 5000.0 1500.0
> 17 6000.0 1500.0
> 18 7000.0 1500.0
> 19 8000.0 1500.0
> 20 9000.0 1500.0
> Number_of_elements
> 39
> Element_connectivity
> 1 1 2 1.0
> 2 2 3 1.000
> 3 3 4 1.00
> 4 4 5 1.0
> 5 5 6 1.000
> 6 6 7 1.0
> 7 7 8 1.0
> 8 8 9 1.0
> 9 9 10 1.0
> 10 10 11 1.000
> 11 12 13 1.0
> 12 13 14 1.0
> 13 14 15 1.0
> 14 15 16 1.0
> 15 16 17 1.0
> 16 17 18 1.0
> 17 18 19 1.0
> 18 19 20 1.0
> 19 2 12 1.0
> 20 3 13 1.0
> 21 4 14 1.0
> 22 5 15 1.0
> 23 6 16 1.0
> 24 7 17 1.0
> 25 8 18 1.0
> 26 9 19 1.0
> 27 10 20 1.0
> 28 1 12 1.0
> 29 3 12 1.0
> 30 3 14 1.0
> 31 5 14 1.0
> 32 5 16 1.0
> 33 7 16 1.0
> 34 7 18 1.0
> 35 9 18 1.0
> 36 9 20 1.0
> 37 11 20 1.0
> 38 6 15 1.0
> 39 6 17 1.0
> Material_properties
> 210000
> Number_of_prescribed_displacements
> 3
> Prescribed_displacements
> 1 1 0.0
> 1 2 0.0
> 11 2 0.0
> Number_of_nodal_loads
> 3
> Nodal_loads
> 5 2 -100000.0
> 6 2 -100000.0
> 7 2 -100000.0
>
>
> This is the one that doesn't open. It contains data on a three-dimensional truss. The program itself work correctly when I input the matrices directly into the m-file, but it refuses to open the text file with fopen:
>
> Number_of_nodes
> 4
> Nodal_coordinates
> 1 0.0 0.0 6000.0
> 2 400.0 0.0 0.0
> 3 -200.0 346.4 0.0
> 4 -200.0 346.4 0.0
> Number_of_elements
> 6
> Element_connectivity
> 1 1 2 1.0
> 2 1 3 1.000
> 3 1 4 1.00
> 4 2 3 1.0
> 5 2 4 1.000
> 6 3 4 1.0
> Material_properties
> 210000
> Number_of_prescribed_displacements
> 9
> Prescribed_displacements
> 2 1 0.0
> 2 2 0.0
> 2 3 0.0
> 3 1 0.0
> 3 2 0.0
> 3 3 0.0
> 4 1 0.0
> 4 2 0.0
> 4 3 0.0
> Number_of_nodal_loads
> 3
> Nodal_loads
> 1 1 -532.33
> 6 2 -330.0
> 7 2 -402.85
> 5 2 -500.0
> 6 2 -500.0
> 7 2 -500.0
>

Hi Gerrit, Use the syntax

[fid, message] = fopen(filename,'r');

and see what message is produced when the file identifies is returned as -1.

Wayne
 | 
Pages: 1
Prev: Zero Padding
Next: Zero Padding