- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I am trying to use matOpen to open and read .mat file but I got this error. Anyone can help me? Here is my code:
program reading
implicit none
integer i,j,mp
real(8), allocatable :: b(:,:)
character(40) :: text
mp=matOpen('motion_1.mat','r')
open(unit=10, file="D:\fortranmatlab\readmatfile\readmatfile\motion.txt.")
do i=1,108001
do j=1,6
write(10,*) b(i,j)
end do
end do
end program reading
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have IMPLICIT NONE, and the name matOpen has not been declared. That is the reason for the message. The program that you showed does not use the variable mp anywhere else, so you could simply remove the matOpen statement. Your program does not make much sense, because it opens a Matlab .mat file for reading, and writes the uninitialized variable b to a text file without going through the Matlab API functions.
On the other hand, if you wish to actually read a Matlab .mat file, you need to consult the Matlab documentation regarding how to do that from Fortran. See the two examples matDemo1.f and matDemo2.f in the extern\examples directory.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page