f



C++ Mex file crashes matlab on 64bit linux, but not 32 bit windows, but program runs fine outside Matlab

Hello,

I have written a mex gateway function to a C++ class. If I compile this mex function on 32Bit windows using R2008a I have no problems. If I compile and run on Matlab R2011a running 64bit Scientific Linux (a version of Red Hat Enterprize Linux) matlab exits with a segfault when the mexfunction is called, although it appears to run about halfway through the program. The C++ class can be compiled and run (with a main function) outside of Matlab on both platforms with no errors. I am using Microsoft Visual C++ Express Edition on the windows machine, and gcc 4.4.5 on the Linux machine.

Can anyone suggest what the cause of this might be and how I can I fix it?

I am having a hard time debugging on Linux as I do not have access to a graphical debugger for use with matlab and am unfamiliar with gdb. This is compounded by the fact that the program compiles and runs fine when compiled as a standalone program.

A zip file containing the code and data files necessary to reproduce the problem can be downloaded from http://www.see.ed.ac.uk/~s0237326/downloads/mexcrash.zip. This zip file contains the .m and .cpp source code, and a text file for testing (Temp.fem). The file fmehsersetup.m shows the commands I am using to compile. The file Test_mexfmesher.m runs the mexfunction with an appropriate input for testing. The mex gateway function is mexfmesher.cpp, it calls the fmesher class which is made up of the files in the fmesher directory.

Below is a backtrace from the segfault:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff721be36 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwservices.so
(gdb) backtrace
#0  0x00007ffff721be36 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwservices.so
#1  0x00000034daa914f2 in std::basic_ostream<char, std::char_traits<char> >::flush() () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libstdc++.so.6
#2  0x00007ffff72302b0 in ioFlush () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwservices.so
#3  0x00007ffff61303f5 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#4  0x00007ffff61330ec in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#5  0x00007ffff6130c7a in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#6  0x00007ffff6131741 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#7  0x00007ffff618a7d9 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#8  0x00007ffff686d7ef in Mfh_file::dispatch_fh(int, mxArray_tag**, int, mxArray_tag**) () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_dispatcher.so
#9  0x00007ffff61731f0 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#10 0x00007ffff6114975 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#11 0x00007ffff612e96e in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#12 0x00007ffff61330ec in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#13 0x00007ffff6130c7a in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#14 0x00007ffff6131741 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#15 0x00007ffff618a7d9 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#16 0x00007ffff686d7ef in Mfh_file::dispatch_fh(int, mxArray_tag**, int, mxArray_tag**) () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_dispatcher.so
#17 0x00007ffff61669b2 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#18 0x00007ffff6128e13 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#19 0x00007ffff6127eb7 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#20 0x00007ffff6128397 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwm_interpreter.so
#21 0x00007ffff6d378fe in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwbridge.so
#22 0x00007ffff6d384ae in mnParser () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwbridge.so
#23 0x00007ffff6ae0d39 in mcrInstance::mnParser_on_interpreter_thread() () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwmcr.so
#24 0x00007ffff6ac3db2 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwmcr.so
#25 0x00007ffff6ac3ec0 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwmcr.so
#26 0x00007fffee8badb6 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/../../bin/glnxa64/libmwuix.so
#27 0x00007fffee8c413d in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/../../bin/glnxa64/libmwuix.so
#28 0x00007fffef3110bd in sysq::during_F<boost::weak_ptr<sysq::ws_ppeHook>, boost::shared_ptr<sysq::ws_ppeHook> > std::for_each<__gnu_cxx::__normal_iterator<boost::weak_ptr<sysq::ws_ppeHook>*, std::vector<boost::weak_ptr<sysq::ws_ppeHook>, std::allocator<boost::weak_ptr<sysq::ws_ppeHook> > > >, sysq::during_F<boost::weak_ptr<sysq::ws_ppeHook>, boost::shared_ptr<sysq::ws_ppeHook> > >(__gnu_cxx::__normal_iterator<boost::weak_ptr<sysq::ws_ppeHook>*, std::vector<boost::weak_ptr<sysq::ws_ppeHook>, std::allocator<boost::weak_ptr<sysq::ws_ppeHook> > > >, __gnu_cxx::__normal_iterator<boost::weak_ptr<sysq::ws_ppeHook>*, std::vector<boost::weak_ptr<sysq::ws_ppeHook>, std::allocator<boost::weak_ptr<sysq::ws_ppeHook> > > >, sysq::during_F<boost::weak_ptr<sysq::ws_ppeHook>, boost::shared_ptr<sysq::ws_ppeHook> >) ()
   from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/../../bin/glnxa64/libuij.so
#29 0x00007fffef312989 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/../../bin/glnxa64/libuij.so
#30 0x00007fffef30f4ae in svWS_ProcessPendingEvents(int, int, bool) () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/../../bin/glnxa64/libuij.so
#31 0x00007ffff6ac21c7 in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwmcr.so
#32 0x00007ffff6ac260a in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwmcr.so
#33 0x00007ffff6ac2d6f in ?? () from /opt/matlab-2011a/bin/glnxa64/../../bin/glnxa64/libmwmcr.so
#34 0x00000034d7a077e1 in start_thread () from /lib64/libpthread.so.0
#35 0x00000034d72e573d in clone () from /lib64/libc.so.6
(gdb) quit

Thanks!
0
r.crozier (95)
11/24/2011 10:01:09 AM
comp.soft-sys.matlab 211266 articles. 15 followers. lunamoonmoon (258) is leader. Post Follow

8 Replies
1591 Views

Similar Articles

[PageSpeed] 47

On 24 Nov, 11:01, "Richard Crozier" <r.croz...@ed.ac.uk> wrote:
> Hello,
>
> I have written a mex gateway function to a C++ class. If I compile this m=
ex function on 32Bit windows using R2008a I have no problems. If I compile =
and run on Matlab R2011a running 64bit Scientific Linux (a version of Red H=
at Enterprize Linux) matlab exits with a segfault when the mexfunction is c=
alled, although it appears to run about halfway through the program. The C+=
+ class can be compiled and run (with a main function) outside of Matlab on=
 both platforms with no errors. I am using Microsoft Visual C++ Express Edi=
tion on the windows machine, and gcc 4.4.5 on the Linux machine.
>
> Can anyone suggest what the cause of this might be and how I can I fix it=
?

Segmentation faults are usually caused by rogue pointers.
These kinds of errors are notoriously hard to track down.

In order to track it down yourself, you need to learn how
to program both C and C++. (Those are two intimatelt related
but different languages).

Rune
0
allnor (8509)
11/24/2011 10:09:12 AM
Rune Allnor <allnor@tele.ntnu.no> wrote in message <77265aa1-d8f8-4e28-8f58-589798cf5f68@j10g2000vbe.googlegroups.com>...
> On 24 Nov, 11:01, "Richard Crozier" <r.croz...@ed.ac.uk> wrote:
> > Hello,
> >
> > I have written a mex gateway function to a C++ class. If I compile this mex function on 32Bit windows using R2008a I have no problems. If I compile and run on Matlab R2011a running 64bit Scientific Linux (a version of Red Hat Enterprize Linux) matlab exits with a segfault when the mexfunction is called, although it appears to run about halfway through the program. The C++ class can be compiled and run (with a main function) outside of Matlab on both platforms with no errors. I am using Microsoft Visual C++ Express Edition on the windows machine, and gcc 4.4.5 on the Linux machine.
> >
> > Can anyone suggest what the cause of this might be and how I can I fix it?
> 
> Segmentation faults are usually caused by rogue pointers.
> These kinds of errors are notoriously hard to track down.
> 
> In order to track it down yourself, you need to learn how
> to program both C and C++. (Those are two intimatelt related
> but different languages).
> 
> Rune

Yes, but is it not curious that the class can be compiled and run outside Matlab with no errors using the same compiler on the same system, but yet it crashes matlab?

I have some familiarity with C and C++ but am not familiar with gdb. On my 64Bit linux system, this is the only tool available for debugging this mex file.

I believe the problem could be related to calls to the 'free' function. Are there any known problems with this?

Thanks,
Richard
0
r.crozier (95)
11/24/2011 10:46:08 AM
On 24 Nov, 11:46, "Richard Crozier" <r.croz...@ed.ac.uk> wrote:
> Rune Allnor <all...@tele.ntnu.no> wrote in message <77265aa1-d8f8-4e28-8f=
58-589798cf5...@j10g2000vbe.googlegroups.com>...
> > On 24 Nov, 11:01, "Richard Crozier" <r.croz...@ed.ac.uk> wrote:
> > > Hello,
>
> > > I have written a mex gateway function to a C++ class. If I compile th=
is mex function on 32Bit windows using R2008a I have no problems. If I comp=
ile and run on Matlab R2011a running 64bit Scientific Linux (a version of R=
ed Hat Enterprize Linux) matlab exits with a segfault when the mexfunction =
is called, although it appears to run about halfway through the program. Th=
e C++ class can be compiled and run (with a main function) outside of Matla=
b on both platforms with no errors. I am using Microsoft Visual C++ Express=
 Edition on the windows machine, and gcc 4.4.5 on the Linux machine.
>
> > > Can anyone suggest what the cause of this might be and how I can I fi=
x it?
>
> > Segmentation faults are usually caused by rogue pointers.
> > These kinds of errors are notoriously hard to track down.
>
> > In order to track it down yourself, you need to learn how
> > to program both C and C++. (Those are two intimatelt related
> > but different languages).
>
> > Rune
>
> Yes, but is it not curious that the class can be compiled and run outside=
 Matlab with no errors using the same compiler on the same system, but yet =
it crashes matlab?

No. That's why these kinds of errors are so hard to track down.

> I have some familiarity with C and C++ but am not familiar with gdb. On m=
y 64Bit linux system, this is the only tool available for debugging this me=
x file.

Then you need to learn how to use gdb.

Or you could debug the code on one of the systems where
you have familiar debuggers. The coding error will be
the same on all platforms.

> I believe the problem could be related to calls to the 'free' function. A=
re there any known problems with this?

The obvious problem would be to free the same pointer twice.
Which is one form of a rogue pointer. (There are several.)

Rune
0
allnor (8509)
11/24/2011 12:33:03 PM
"Richard Crozier" wrote in message <jal79g$88d$1@newscl01ah.mathworks.com>...
> Rune Allnor <allnor@tele.ntnu.no> wrote in message <77265aa1-d8f8-4e28-8f58-589798cf5f68@j10g2000vbe.googlegroups.com>...
> > On 24 Nov, 11:01, "Richard Crozier" <r.croz...@ed.ac.uk> wrote:
> > > Hello,
> > >
> > > I have written a mex gateway function to a C++ class. If I compile this mex function on 32Bit windows using R2008a I have no problems. If I compile and run on Matlab R2011a running 64bit Scientific Linux (a version of Red Hat Enterprize Linux) matlab exits with a segfault when the mexfunction is called, although it appears to run about halfway through the program. The C++ class can be compiled and run (with a main function) outside of Matlab on both platforms with no errors. I am using Microsoft Visual C++ Express Edition on the windows machine, and gcc 4.4.5 on the Linux machine.
> > >
> > > Can anyone suggest what the cause of this might be and how I can I fix it?
> > 
> > Segmentation faults are usually caused by rogue pointers.
> > These kinds of errors are notoriously hard to track down.
> > 
> > In order to track it down yourself, you need to learn how
> > to program both C and C++. (Those are two intimatelt related
> > but different languages).
> > 
> > Rune
> 
> Yes, but is it not curious that the class can be compiled and run outside Matlab with no errors using the same compiler on the same system, but yet it crashes matlab?
> 
> I have some familiarity with C and C++ but am not familiar with gdb. On my 64Bit linux system, this is the only tool available for debugging this mex file.
> 
> I believe the problem could be related to calls to the 'free' function. Are there any known problems with this?
> 
> Thanks,
> Richard

Further to this, my question has effectively been answered by Jan Simon here:

http://www.mathworks.com/matlabcentral/answers/22144-c-mex-file-crashes-matlab-on-64bit-linux-but-not-32-bit-windows-but-program-runs-fine-outside-ma
0
r.crozier (95)
11/24/2011 12:43:07 PM
> Or you could debug the code on one of the systems where
> you have familiar debuggers. The coding error will be
> the same on all platforms.
> 

My specific problem, as stated, was that the error did not occur on all platforms. Only on 64Bit Linux, and only when compiled as a matlab mex file, rather than being called from a main function in a standalone program. So I'm not sure what you mean?

> > I believe the problem could be related to calls to the 'free' function. Are there any known problems with this?
> 
> The obvious problem would be to free the same pointer twice.
> Which is one form of a rogue pointer. (There are several.)

The actual problem was I was trying to 'free' memory which pointed to NULL.

Thanks for the help anyway!
0
r.crozier (95)
11/24/2011 12:48:08 PM
On 24 Nov, 13:48, "Richard Crozier" <r.croz...@ed.ac.uk> wrote:
> > Or you could debug the code on one of the systems where
> > you have familiar debuggers. The coding error will be
> > the same on all platforms.
>
> My specific problem, as stated, was that the error did not occur on all platforms. Only on 64Bit Linux, and only when compiled as a matlab mex file, rather than being called from a main function in a standalone program. So I'm not sure what you mean?

A rogue pointer is a pointer that points somewhere else than
you, the programmer, thinks it does. Where that 'other' location
might be, varies from situation to situation (between platforms,
compiler mode, MEX&standalone,...) and the concequences of that
error varies depends on the situation and what you attempt to do.

If the pointer refers to not allocated space, then a seg fault
will occur when you try dereferncing it.

If the pointer points to allocated memory and you read data,
you will read invalid data and the computation results downstream
will give invalid results.

If the pointer points to allocated memory and you attempt to
write to th elocation, you might cause some program module
that is totally unrelated to where the coding error occurs,
cause a seg fault.

Freeing null pointers is the easiest such error to find,
so if that was the cause of problem you might count yourself
lucky. The somewhat disturbing question is what other errors
might reside in a code where the most trivial of all rogue
pointers have been discovered.

Rune
0
allnor (8509)
11/24/2011 1:02:12 PM
Rune Allnor <allnor@tele.ntnu.no> wrote in message <9aba748a-9eef-43b6-a2e4-8b8896125876@u5g2000vbd.googlegroups.com>...
> On 24 Nov, 13:48, "Richard Crozier" <r.croz...@ed.ac.uk> wrote:
> > > Or you could debug the code on one of the systems where
> > > you have familiar debuggers. The coding error will be
> > > the same on all platforms.
> >
> > My specific problem, as stated, was that the error did not occur on all platforms. Only on 64Bit Linux, and only when compiled as a matlab mex file, rather than being called from a main function in a standalone program. So I'm not sure what you mean?
> 
> A rogue pointer is a pointer that points somewhere else than
> you, the programmer, thinks it does. Where that 'other' location
> might be, varies from situation to situation (between platforms,
> compiler mode, MEX&standalone,...) and the concequences of that
> error varies depends on the situation and what you attempt to do.
> 
> If the pointer refers to not allocated space, then a seg fault
> will occur when you try dereferncing it.
> 
> If the pointer points to allocated memory and you read data,
> you will read invalid data and the computation results downstream
> will give invalid results.
> 
> If the pointer points to allocated memory and you attempt to
> write to th elocation, you might cause some program module
> that is totally unrelated to where the coding error occurs,
> cause a seg fault.
> 
> Freeing null pointers is the easiest such error to find,
> so if that was the cause of problem you might count yourself
> lucky. The somewhat disturbing question is what other errors
> might reside in a code where the most trivial of all rogue
> pointers have been discovered.
> 
> Rune

in this code the functions 'malloc' and 'free' are used only to generate some input for an old 'C' file routine (triangle.c in the example code) in two places. The rest of the code was mostly written by a more experienced C++ programmer, and has been very extensively tested. I think if I clean up my own additions, there is some hope it will be safe, but we shall see.

 
0
r.crozier (95)
11/24/2011 1:47:08 PM
On 24 Nov, 14:47, "Richard Crozier" <r.croz...@ed.ac.uk> wrote:
> Rune Allnor <all...@tele.ntnu.no> wrote in message <9aba748a-9eef-43b6-a2=
e4-8b8896125...@u5g2000vbd.googlegroups.com>...
> > On 24 Nov, 13:48, "Richard Crozier" <r.croz...@ed.ac.uk> wrote:
> > > > Or you could debug the code on one of the systems where
> > > > you have familiar debuggers. The coding error will be
> > > > the same on all platforms.
>
> > > My specific problem, as stated, was that the error did not occur on a=
ll platforms. Only on 64Bit Linux, and only when compiled as a matlab mex f=
ile, rather than being called from a main function in a standalone program.=
 So I'm not sure what you mean?
>
> > A rogue pointer is a pointer that points somewhere else than
> > you, the programmer, thinks it does. Where that 'other' location
> > might be, varies from situation to situation (between platforms,
> > compiler mode, MEX&standalone,...) and the concequences of that
> > error varies depends on the situation and what you attempt to do.
>
> > If the pointer refers to not allocated space, then a seg fault
> > will occur when you try dereferncing it.
>
> > If the pointer points to allocated memory and you read data,
> > you will read invalid data and the computation results downstream
> > will give invalid results.
>
> > If the pointer points to allocated memory and you attempt to
> > write to th elocation, you might cause some program module
> > that is totally unrelated to where the coding error occurs,
> > cause a seg fault.
>
> > Freeing null pointers is the easiest such error to find,
> > so if that was the cause of problem you might count yourself
> > lucky. The somewhat disturbing question is what other errors
> > might reside in a code where the most trivial of all rogue
> > pointers have been discovered.
>
> > Rune
>
> in this code the functions 'malloc' and 'free' are used only to generate =
some input for an old 'C' file routine (triangle.c in the example code) in =
two places. The rest of the code was mostly written by a more experienced C=
++ programmer, and has been very extensively tested. I think if I clean up =
my own additions, there is some hope it will be safe, but we shall see.

Well, the problem with rogue pointersis that
unless they seg fault, they are likely to pass
any tests you might throw at them. A test
would go as follows:

1) Allocate memory
2) Write something to that memory
3) Read data back from the memory
4) Compare and see that what you read
   back equals what you wrote
5) Deallocate the memory

If something goes wrong in this process in a way
that does not case a seg fault, the code will
pass the test.

If ypu mean "the code has worked without problems
for a long time" it only means that you haven't
*discovered* any poblems. It does *not* mean that
there are no problems to be discovered.

Rune
0
allnor (8509)
11/24/2011 2:08:59 PM
Reply:

Similar Artilces:

Why can't Fortran-mex files be compiled on matlab V5.3 and run on matlab V6?
Hi, does anyone know why Fortran-mex files can't be compiled on matlab V5.3 and run on matlab V6? For example: if I compile the example-program (shipped with matlab) timestwo.f on matlab version 5.3 (R11) and try to run it on matlab version 6+ (R12 or R13), I get the error message: "Unable to load mex file: E:\timestwo.dll. The specified module could not be found. ??? Invalid MEX-file" Likewise if I compile it on matlab version 6.1 (R12), I get a similar error message if run on matlab version 5.3 (R11). However, if I run it on matlab version 6.5 it works OK. If I try the same experiment with the corresponding example file written in C, timestwo.c, I get no such problems. Why is that? Per A. Hi Per, usually MEX-files need to be compiled with the MATLAB version you want it later to run with. The reason is, that the code links against the current dynamic libraries (DLLs), which may change from version to version. You may have luck that it works (see your example of timestwo.f), but you should never rely on this. Titus "Per A. Brodtkorb" <Per.Brodtkorb@ffi.no> wrote in message news:eecb303.-1@webx.raydaftYaTP... > Hi, > > does anyone know why Fortran-mex files can't be compiled on matlab > V5.3 and run on matlab V6? > > For example: if I compile the example-program (shipped with matlab) > timestwo.f > on matlab version 5.3 (R11) and try to run > it on matlab version 6+ (R12 or R13), I ...

Matlab crashes when running fortran mex file
First of all, I have ubuntu with gfortran 4.6.1 and f95 4.6.1compiler and I am using the mtlab R2007a. The problem is when I compile the examples code "timetwo.F" given in matlabroot/extern/examples/refboof, compilations goes through but when I run it in the matlab, matlab crashes. I think I have library compatibity issues because the code runs fine on my other machine which have older libraries. Here is what are the libraries in my matlabR2007a/sys/os/glnxa64 folder: libgfortran.so.1 -> /usr/lib/x86_64-linux-gnu/libgfortran.so.3 libiberty.so libXm.so.3 -> libXm.so.3.0.1 libXm.so.3 Note that I have pointed libgfortran.so.1 to the system fortran library rather than the one that came with matlab. But even if I do not change (keep the same that came with matlab), output is the same. It crashes. =========== Also does someone know wht we need to have the libgfortran.so.1 file. Why doesnt it take this library from the system libraries like other C libraries. I am saying this because when I do not have this library and try to start the matlab I get this error: libmwlapack: load error: libgfortran.so.1: cannot open shared object file: No such file or directory terminate called after throwing an instance of 'std::runtime_error' what(): libgfortran.so.1: cannot open shared object file: No such file or directory Aborted Please help me... I am banging my head over this. On 30 Nov, 00:17, "AA " <arvind...@gmail.com&g...

Shall i use the misrosoft Visual c++ code from a m-file generated from matlab in Visual C++ with out matlab runtime environment
undefined ...

32-bit Matlab on 64-bit Linux
Hi, I've some mex code(compiled by somebody else on 32-bit machines) but I currently have a 64-bit version of Matlab installed on 64-bit ubuntu. I saw this suggestion from somebody- http://www.mathworks.cn/matlabcentral/newsreader/view_thread/100595 "The fix (since you can't recompile the .mex files) is to run the x86 version of Matlab, which you can install alongside the native x86_64 version. Once you've done that, whenever you need to run your .mexglx files, start Matlab with 'matlab -glnx86'." So I decided to search if this was actually possible and I found two threads from mathworks.com which I personally believe contradict each other with their answers- http://www.mathworks.com/support/solutions/en/data/1-O7POO/ http://www.mathworks.com/support/solutions/en/data/1-1CAT7/ So my question is whether 32-bit matlab can be installed on a 64bit machine ? Thanks On Sep 29, 1:09=A0pm, "Gautam " <gautam.iiith...@gmail.com> wrote: > Hi, > > I've some mex code(compiled by somebody else on 32-bit machines) but I cu= rrently have a 64-bit version of Matlab installed on 64-bit ubuntu. > > I saw this suggestion from somebody-http://www.mathworks.cn/matlabcentral= /newsreader/view_thread/100595 > "The fix (since you can't recompile the .mex files) is to run the x86 ver= sion of Matlab, which you can install alongside the native x86_64 version. = Once you've done that, whenever you need to run your .m...

Mex file crashes Matlab
Hello all, I created successfully a mex file. It is linked to an external dll and it worked fine (it returns correctly to matlab a vector). Recently I added an new function inside my c++ file which does not affect the result of the c++ function but is just used to improve some data manipulation. By the way, this function works quite well in a simple c++ file and I have already used many times in other c++ files (no-mex files). After added this function my matlab crashes and returns me this error: MATLAB crash file:C:\DOCUME~1\MILCEMEA~1.VAA\LOCALS~1\Temp\matlab_crash_dump.2996 ------------------------------------------------------------------------ Segmentation violation detected at Wed Jul 28 18:38:04 2010 ------------------------------------------------------------------------ Operating System: Microsoft Windows XP Window System: Version 5.1 (Build 2600: Service Pack 3) Processor ID: x86 Family 6 Model 7 Stepping 10, GenuineIntel Virtual Machine: Java 1.6.0_04-b12 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode Default Encoding: windows-1252 Fault Count: 1 Register State: EAX = ffff5df8 EBX = 00c2e01c ECX = ffffffff EDX = e06d7363 ESI = ffff5df4 EDI = 04f169ec EBP = 00c2e028 ESP = 00c2cf40 EIP = 04ec186e FLG = 00010286 Stack Trace: [0] qlDiscountFactors.mexw32:0x04ec186e(0x00c2e158 "x£", 0x00c2e0b8, 0x00c2e1fc, 0) [1] 0x00c2e20c(0x8b00032b, 0x04c483d8, 0x85e85d89,...

What is the best way to import Excel files, with stock data, into Matlab? I’m using Matlab R2010b (64-bit)
What is the best way to import Excel files, with stock data, into Matlab? I’m using Matlab R2010b (64-bit) I’m trying to import historical prices of stock data. Matlab keeps cutting off the header of each column; it gives me only values. I am thinking that this is a data-type-mixing-issue, or whatever it’s called. I have ‘Dates’ in ColumnA, and ‘MSFT’, ‘PWER’, ‘KO’, and ‘SBUX’, in ColumnB-ColumnE. Basically, if I put the Excel file in my Matlab folder and double-click the file, I see the values in a matrix (no dates and no headers), I hit ‘Next’. Then, I see only one option; one radio button is enabled – ‘Create variable matching preview’. The other two options, ‘Create vectors from each column using column names’ and ‘Create vectors from each row using row names’ – both are greyed out. I’ve seen videos, on YouTube and on the Matlab site, where people import excel data and these options are NOT greyed out. No matter what I do, there options are ALWAYS greyed out. The problem is, when I click ‘Finish’ in my ‘Workspace’ I have a variable named ‘data’ all values in a 575x4 matrix, but I have NO DATES and I have NO HEADERS on the columns. All of this seems to go into another variable, called ‘textdata’; all dates and headers ate in textdata. This is VERY inconvenient. I’m trying to analyze some stock data and I have no headers, so I have no idea which stock is which (I can figure it out, but I think Matlab should do this for me). Also, I have no dates corresponding to ...

Calling MATLAB from a C++ program in Linux
Hi there, I'm trying to call the MATLAB engine from some C++ which I'm writing. I'm using Debian 6.0.4 64 bit. GCC version is 4.4.5-8. In order to test out what the built in engine can do, I thought a good place to start would be to compile one of the demos which comes with MATLAB (in this case, engdemo.cpp). I've install csh and when I call g++ engdemo.cpp, these are the errors I get: % g++ engdemo.cpp /tmp/ccD4qsD5.o: In function `main': engdemo.cpp:(.text+0xa8): undefined reference to `engOpen' engdemo.cpp:(.text+0xf4): undefined reference to `mxCreateDoubleMatrix' engdemo.cpp:(.text+0x104): undefined reference to `mxGetPr' engdemo.cpp:(.text+0x12d): undefined reference to `engPutVariable' engdemo.cpp:(.text+0x13e): undefined reference to `engEvalString' engdemo.cpp:(.text+0x14f): undefined reference to `engEvalString' engdemo.cpp:(.text+0x160): undefined reference to `engEvalString' engdemo.cpp:(.text+0x171): undefined reference to `engEvalString' engdemo.cpp:(.text+0x182): undefined reference to `engEvalString' engdemo.cpp:(.text+0x1b1): undefined reference to `mxDestroyArray' engdemo.cpp:(.text+0x1c2): undefined reference to `engEvalString' engdemo.cpp:(.text+0x1e1): undefined reference to `engOutputBuffer' engdemo.cpp:(.text+0x24e): undefined reference to `engEvalString' engdemo.cpp:(.text+0x282): undefined reference to `engGetVariable' engdemo.cpp:(.text+0x2aa): und...

Call Matlab m-file from Matlab Scrip Node
My problem with matlab script node is related to calling function in matlab.&nbsp; I created an m-file function that takes an imput temperature (from DAQ) and defines a material property.&nbsp; My matlab script node doesn't seem to recognize my function.&nbsp; I have placed the function in the folder the vi is currently located, but it doesn't read it.&nbsp; How do I get matlab script node to read the functions I create in matlab? Add the directory to matlab path, or call the .m file with it full name ( D:\..... \myfile.m) Let me clarify, &nbsp; I have pasted my matlab code into the matlab scrip node. &nbsp; In this code, I have called a subfunction that I have created. &nbsp; Example k(n)=k_c(T(n)) where k_c is a subfunction I have created. &nbsp; How do I get my code in the node&nbsp;to sucessfully read the subfunction k_c? &nbsp; &nbsp; &nbsp; As indicated, you need to add the directory where the .m file containing the function resides to the list of paths that are read in. This is your startup.m file. The other option is to do a "cd" command prior to calling your function to change to the directory where the .m file containing the function resides. Thanks for reiterating the information.&nbsp; My matlab script node is working properly.&nbsp; I had never used the "cd" command in matlab.&nbsp; I always set the working directory when I open the program, and put all the m files into t...

A Matlab (Windows 64bits) to Java (Linux 32bits) converter
Hi everybody, I am faced to a problem I am trying to solve for one week at full time. :-( I have a Matlab program without input argument. I have written it in a windows 64bits Matlab. I now need to translate this code into a java (Eclipse) source that will be used from a maximum 512MB Ram device. I cannot use the Matlab Builder JA because the MATLAB Compiler Runtime (MCR) needs at least 1GB Ram. I desperatly trying to find a solution, in vain! Nobody could help me? Is my problem clear enough? "lala " <thib712@hotmail.com> wrote in message <jjvlnh$7k3$1@newscl01ah.mathworks.com>... > Hi everybody, > > I am faced to a problem I am trying to solve for one week at full time. :-( > I have a Matlab program without input argument. > I have written it in a windows 64bits Matlab. > I now need to translate this code into a java (Eclipse) source that will be used from a maximum 512MB Ram device. I cannot use the Matlab Builder JA because the MATLAB Compiler Runtime (MCR) needs at least 1GB Ram. I desperatly trying to find a solution, in vain! ...

Matlab engine with matlab R2010b
Hello All, I'm working with an aplication that use the matlab engine. I made the C++ program and it is working well in my pc with matlab 2007b, but the same very basic program shows an error when I tried to compile it in a pc with matlab R2010b. The error is about the icuuc32.dll. ¿Why is asking this DLL? How can I solve this?. Thanks¡ ...

can't run matlab setup/No puedo correr matlab
Hi! I opened the&nbsp;matlab script fractal.vi&nbsp;then my antivirus (Kaspersky)&nbsp;ask&nbsp;if I acept the modified te registry of matlab setup,&nbsp; I &nbsp;say "yes" After that when I want open matlab the setup run but inmediatly it's close, why???? &nbsp; Hola: Abri el matlab script fractal.vi y mi antivirus (Kasoersky)me preguntaba si aceptaba una modificacion del registro del setup de matlab yo acepte Despues de eso cuanto abro matlab se cierra inmediatamente porque?? &nbsp; &nbsp; &nbsp; Hola Sa�l Es probable que el problema est� relacionado con el antivirus Kaspersky, trata de deshabilitarlo y correr nuevamente el ejemplo.&nbsp; Si esto no funciona revisa el estado de tus licencias de LabVIEW y de Matlab, probablemente tengas que reinstalar el programa y/o activar las licencias. �Qu� versi�n de LabVIEW y Matlab tienes? �El comportamiento es el mismo con el otro ejemplo?, me refiero al de la siguiente dir: labview\examples\scriptnode\Differential Equation.llb\MATLAB Script - Lorenz Diff Eq.vi Si corres este ejemplo �El antivirus tambi�n te pregunta cambiar lo de los registros?, ser�a bueno contactar a Mathworks para saber c�mo reconfigurar nuevamente los registros de Matlab ...

Matlab crashes when print from my custom function in c-mex s-function code
I have a c-mex s-function file in which I have written several custom functions. I have no problems printing to output files from most of these custom functions, but the one below continually crashes Matlab whenever I try to print to file from this function. This is odd, because, from what I can see, the syntax below follows that used in all of my other custom functions, so I'm not sure what's going wrong. Can anyone spot the problem with the code below, that causes Matlab to crash when the write-to-file statements are active? (When I comment those lines out, the function runs without crashing, although I suspect that this function is generating the wrong values, which is why I need to view them.) ------------------------------------------------------------------- static void mdlRLgetState(SimStruct *S){ FILE *out1; real_T *Dwork_ShAng = (real_T*) ssGetDWork(S,0); real_T *Dwork_ElbAng = (real_T*) ssGetDWork(S,1); real_T *Dwork_state0 = (real_T*) ssGetDWork(S,48); real_T *Dwork_state1 = (real_T*) ssGetDWork(S,49); /* it also crashes if I declare FILE *out1 here, instead */ out1 = ("AA_mdlRLgetState.log","a"); Dwork_state0[0] = Dwork_ShAng[0]; Dwork_state1[0] = Dwork_ElbAng[0]; fprintf(out1, "Dwork_state0[0] = %f, 1 = %f \n", Dwork_state0[0],Dwork_state1[0]); fclose(out1); } /* mdlRLgetState() function */ ---------...

Incompatible of MAT file for Matlab 6.5.1 and Matlab 7.0
Hi! I have recently installed Matlab 7.0. I have save my simulation results in .MAT file. However, these MAT files can't be opened using Matlab 6.5.1. I encountered problem as follows: ??? Error using ==> load Unable to read MAT file D:\MATLAB7\work\results.mat File may be corrupt. How can I solve this problem? Thanks. Linda Please see here: <http://tx.technion.ac.il/~perryb/matlab7/mat7.pdf> In short, save again as: The new features and enhancements are described in the "Release notes" of Matlab. A new feature that causes incompatibility with previous versions of Matlab is the new encoding of MAT files. Matlab release 14 writes character and figure data to MAT-files using Unicode encoding by default. Unicode encoded MAT-files are not readable by earlier versions of Matlab. If you intend to load your MAT-files created with Matlab release 14, you must override the Unicode default during the save. You can override the default encoding by using the -v6 switch with save and hgsave: save filename -v6 hgsave filename -v6 Hope it helps Linda wrote: > > > Hi! > > I have recently installed Matlab 7.0. > I have save my simulation results in .MAT file. > However, these MAT files can't be opened using Matlab 6.5.1. > > I encountered problem as follows: > > ??? Error using ==> load > Unable to read MAT file D:\MATLAB7\work\results.mat > > File ma...

64bit matlab for windows x64???
64bit matlab for windows x64??? is this in developement? whats the eta on it being available? ...

MATLAB FFTW MEX CRASH
I'm trying to compile FFTW library functions into a mex C++ file. I managed to compile the file successfully. "mex filename.cpp -I/path/to/include -L/path/to/lib -lm -lfftw3 -output test" But when I run from MATLAB cmd window, MATLAB will crash with segmentation fault. Anyone has any suggestions, thanks the code is very simple as follows: #include "mex.h" #include "stdlib.h" #include "stdio.h" #include "fftw3.h" /* $Revision: 1.8.6.3 $ */ void timestwo(double y[], double x[]) { y[0] = 2.0*x[0]; } void test_fftw() { int N=8; double *in, *in2; fftw_complex *out; fftw_plan p, p_rev; in = (double*)fftw_malloc(sizeof(double)*N); in2 =(double*) fftw_malloc(sizeof(double) * N); out = (fftw_complex*)fftw_malloc(sizeof(fftw_complex) * N); fftw_free(in); fftw_free(in2); fftw_free(out); } void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { double *x,*y; mwSize mrows,ncols; /* Check for proper number of arguments. */ if(nrhs!=1) { mexErrMsgTxt("One input required."); } else if(nlhs>1) { mexErrMsgTxt("Too many output arguments."); } /* The input must be a noncomplex scalar double.*/ mrows = mxGetM(prhs[0]); ncols = mxGetN(prhs[0]); if( !mxIsDouble(prhs[0]) || mxIsComplex(prhs[0]) || !(mrows==1 && nco...

Can ActiveX server on 64-bit MATLAB open a 32-bit app?
Hello, Does anybody know if the ActiveX server of 64-bit MATLAB can open a 32-bit application running on a 64-bit Windows 7? It looks like I lost this capability after upgrading to 64-bit machine... Thank you! Did you find the solution? As per http://www.mathworks.com/products/matlab/preparing-for-64-bit-windows.html it cannot. Phil. ...

matlab and c#
hello, can anyone tell me how to connect between matlab and c#? is it using COM? or how? and it is done in c# or matlab or both? can anybody help me pls Thanx, Victor Search for "c sharp" on the MathWorks support page. Stuart "victor hugo" <dvictor_hugo@yahoo.com> wrote in message news:eee4ca3.-1@webx.raydaftYaTP... > hello, > > can anyone tell me how to connect between matlab and c#? is it using > COM? or how? and it is done in c# or matlab or both? > > can anybody help me pls > > Thanx, > > Victor ...

matlab C#
------------------------------------------------------------------------ Segmentation violation detected at Fri Mar 09 09:32:14 2012 ------------------------------------------------------------------------ Configuration: MATLAB Version: 7.0.0.19920 (R14) Operating System: Microsoft Windows XP Window System: Version 6.1 (Build 7600) Processor ID: x86 Family 6 Model 7 Stepping 10, GenuineIntel Virtual Machine: Java is not enabled Default Charset: ibm-1386_P100-2002 Register State: EAX = 00000001 EBX = 011c1bd8 ECX = 011c1bd8 EDX = 77346194 ESI = 00000000 EDI = 00000000 EBP = 053cf198 ESP = 053cf190 EIP = 78215da8 FLG = 00010202 Stack Trace: [0] jvm.dll:0x78215da8(0x011c1bd8, 0x781d019e, 0x79b67568 "e:\MATLAB7/sys/java /jre/win32/jr..", 8) [1] jvm.dll:0x781cdfa0(0x053cfa9c, 0x79b67568 "e:\MATLAB7/sys/java/jre/win32/j r..", 0x7c3428cf, 0x053cfac4) [2] jvm.dll:0x7817ac0b(0x79b66d30, 0x053cfac0, 0x053cfa9c, 0x7c3536ed) [3] jmi.dll:struct JNIEnv_ * __cdecl InitSunVM(bool)(0, 0x79b5e804 "MATLAB_JDB ", 0x053cfae0, 0x50000000) + 941 bytes [4] jmi.dll:_InitJava(0, 0x793069ed, 0, 0) + 77 bytes [5] jmi.dll:_mljInit(0x04508770, 1, 0, 0) + 6 bytes [6] mcr.dll:unsigned long __cdecl run_init_and_handle_events(void *)(1895368, 0x053cfdc8, 0x7735b299, 1895368) + 47 bytes [7] KERNEL32.dll:0x77491114(1895368, 0x7236b879, 0, 0) [8] ntdll.dll:0x7735b299(0x79306bd0, 18953...

matlab-like command window for c++
Hi all, I have been using Matlab since I bought it a couple years back. I am trying to learn C++ now on a linux machine using emacs editor. This is fine. However, C++ does not have a command window like Matlab with the capability to nicely display matrices and vector outputs or to directly run functions from. Is there any way I can somehow run my C++ functions in matlab without much modifications to the raw C++ code so that vectors and matrices would be output in Matlab environment. Or, is there a matlab-like command window out there for C++ I'm not aware off? thanks, ben "ben " <cloader41@gmail.com> wrote in message <jna752$rih$1@newscl01ah.mathworks.com>... > Hi all, > > I have been using Matlab since I bought it a couple years back. I am trying to learn C++ now on a linux machine using emacs editor. This is fine. However, C++ does not have a command window like Matlab with the capability to nicely display matrices and vector outputs or to directly run functions from. > > Is there any way I can somehow run my C++ functions in matlab without much modifications to the raw C++ code so that vectors and matrices would be output in Matlab environment. Or, is there a matlab-like command window out there for C++ I'm not aware off? In general, no. What you *can* do is use the mex interface (see External Interfaces section in the doc) to get your variables over to MATLAB for display. This may involve reworking some of your...

Contribute to MATLAB Central and Win a MATLAB Jacket
Many of you who post to this newsgroup are also regular contributors to the MATLAB Central File Exchange. Look for your favorite contributors on our File Exchange Author Profile page. You can read their profiles and see pictures: <http://www.mathworks.com/matlabcentral/reports/fileexchange/allProfiles/> In a random drawing, we recently awarded MATLAB jackets to three File Exchange authors with profile pages: Michele Giugliano, Andrey Egin, and Denis Gilbert. You can win a jacket, too. Just submit a new file to the File Exchange or update your author profile by December 2003 for a chance to win one of four MATLAB jackets. See the jacket below: <http://www.mathworks.com/matlabcentral/images/jeff3.jpg> Here are some interesting File Exchange facts: - Since its inception in 2001, visitors have downloaded more than 1.25 million submissions from the File Exchange. - In September 2003 alone, visitors downloaded 80,085 files, an average of 2670 a day! .... what if the prize was a free copy of the next version of Matlab :-) majb Min Poh wrote: ....or an offer for employment... aj "bourassa" <bourassa-m@rmc.ca> wrote in message news:3f9d507d$1@rmcnt03a.rmc.ca... > ... what if the prize was a free copy of the next version of Matlab :-) > > majb > > Min Poh wrote: > ...

Matlab parallel for loop or Matlab open pool
I am trying to to some computations and I would like to do it in parallel using parfor or by Opening the matlabpool.. as the current implementations is too slow: result=zeros(25,16000); for i = 1:length(vector1) % length is 25 for j = 1:length(vector2) % length is 16000 temp1 = vector1(i); temp2 = vector2(j); t1 = load(matfiles1(temp1).name) %load image1 from matfile1 t2 = load(matfiles2(temp2).name) % load image2 from matfile2 result(i,j)=t1.*t2 end end It work fine but I would really like to know if there is a way to speed thing up ... Thanks a lot in advance! ...

matlab file
i need to know how we calculate euclideandistance of a bitstream/codeword based on the channel gain of that particular codeword/bitstream subchannel ...

problems getting MATLAB data in C++ program
Hi I am using the MX functions to get read MATLAB data in C and have been able to read the MATLAB data for MATLAB arrays and structures (created using the keword struct) but am having issues reading the data from a MATLAB structure array like test(1).dataelement1, test(1).dataelement2. Does anyone know what mx method to use? Also I think MATLAB must store additional information about the structure array as if I set the variable that I bring over to C to the first element in MATLAB I can read only the first value of the structure array. Any ideas? "Paul" wrote in message <jdd3rc$km1$1@newscl01ah.mathworks.com>... > Hi I am using the MX functions to get read MATLAB data in C and have been able to read the MATLAB data for MATLAB arrays and structures (created using the keword struct) but am having issues reading the data from a MATLAB structure array like test(1).dataelement1, test(1).dataelement2. Does anyone know what mx method to use? Also I think MATLAB must store additional information about the structure array as if I set the variable that I bring over to C to the first element in MATLAB I can read only the first value of the structure array. Any ideas? Use mxGetField. E.g., if you pass in the structure as the first argument: mxArray *test_dataelement1, *test_dataelement2; : test_dataelement1 = mxGetField(prhs[0],0,"dataelement1"); test_dataelement2 = mxGetField(prhs[0],0,"dataelement2"); James Tursa "James Tursa&...

Create icon on desktop and run matlab files
Hello !! I have created a matlab program and i would like to create a icon on desktop to run my program without opening matlab and press the run button ! I want to make my program be able to be runned from people they dont know about program tools ... "Konstantinos Bonis" <malias_g7@hotmail.com> wrote in message news:jca57o$kf8$1@newscl01ah.mathworks.com... > Hello !! > I have created a matlab program and i would like to create a icon on > desktop to run my program without opening matlab and press the run button > ! I want to make my program be able to be runned from people they dont > know about program tools ... Either use the -r startup option to start MATLAB as the target of your shortcut or, if you don't want MATLAB to be visibly opened, use MATLAB Compiler to generate a standalone application. http://www.mathworks.com/help/techdoc/matlab_env/f8-4994.html http://www.mathworks.com/help/toolbox/compiler/ -- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com Im trying to generate a standalone application by using Matlab Compiler but i have some problems.. Im trying to do it by usning the : mcc -mv squareA.m which i found here http://www.mathworks.com/help/toolbox/compiler/f7-996249.html but its saying me to choose a compiler and i dont know what to do .. Im sorry for so many questions but its the first time trying to do it and i found things a bit hard....

Web resources about - C++ Mex file crashes matlab on 64bit linux, but not 32 bit windows, but program runs fine outside Matlab - comp.soft-sys.matlab

Lightning Crashes - Wikipedia, the free encyclopedia
" Lightning Crashes " is a song by the rock band Live , from their 1994 album, Throwing Copper . The track wasn't released as a single in the ...

When New York Times website crashes, newspaper turns to Facebook Notes
When The New York Times’ website suffered some downtime Wednesday because of technical issues, the newspaper turned to Facebook Notes to post ...


NEW Car Crash Compilation November 2014 - Car Crashes Weekly #30 - YouTube
The new stupid, horrible and funny car crashes compilation 2014, 27-31 October and 01-03 November. Car crash compilation of Fall. Thirtieth week ...

Facebook crashes in rare global outage
Users in the UAE were unable to access Facebook after it crashed just after midday on Thursday.

Worst Driver of the Day: Old Man Crashes Into Everything In Piggly Wiggly Parking Lot
No, this isn’t footage from “GTA V.” A 92-year-old man named Russell Kerr pulled his minivan out of the parking lot last Friday at a Piggly Wiggly ...

Thief crashes stolen car from West Lakes Shore break-in - AdelaideNow Search Search
TWO cars were stolen in a break-in at West Lakes Shore overnight - one which was later involved in a police pursuit, the other in a crash this ...

Police Minister Bill Byrne compares crashes to terrorism
If terrorists killed as many as crashes, there would be an outcry: Minister.

Ute crashes in to bus stop
It’s been the talk of Howard Springs – a ute abandoned after it was crashed into a bus shelter.

Car crashes into Sydney church during Easter service
A car has driven through a group of parishioners&nbsp;and through the front wall of a church after an Easter service in Sydney's north-west on ...

Resources last updated: 3/30/2016 3:39:41 PM