Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

messenger / ZMQ session error upon "Matlab clear all" using 'magic' #70

Closed
bs448c opened this issue May 15, 2014 · 5 comments · Fixed by #150
Closed

messenger / ZMQ session error upon "Matlab clear all" using 'magic' #70

bs448c opened this issue May 15, 2014 · 5 comments · Fixed by #150

Comments

@bs448c
Copy link

bs448c commented May 15, 2014

As outlined in #56 and #69 I manage to build pymatbridge-0.3-dev under WIndows 8.1 64 bit. I can start the matlabserver and pass back and forth variables between MATLAB and my iPython notebook (Anaconda 1.9.1, Python 2.7.6) using 'magic' (the x=x+1 and a=[1,2,3]

%%matlab -i a -o b,c
b = a + 3
c = b + 3

sort of examples)

However when trying to port a more complex example,

%%matlab -o x,xf

%Author: Osama Ullah Khan,
%        Phd Student, University of Michigan-Ann Arbor.
%        Email: oukhan@umich.edu
%        Version: 1.0
%
%This code demonstrate compressive sensing example. In this
%example the signal is sparse in frequency domain and random samples
%are taken in time domain.

close all;
clear all;

%setup path for the subdirectories of l1magic
path(path, 'C:\MATLAB\R2013a\l1magic\Optimization');
path(path, 'C:\MATLAB\R2013a\l1magic\Data');


%length of the signal
N=1024;

%Number of random observations to take
K=256;

%Discrete frequency of two sinusoids in the input signal
k1=29;
k2=59;
k3=109;

n=0:N-1;

%Sparse signal in frequency domain.
x=sin(2*pi*(k1/N)*n)+sin(2*pi*(k2/N)*n)+sin(2*pi*(k3/N)*n);

xf=abs(fft(x));

my matlabserver fails:

MATLAB is running in headless mode.  Figure windows will not be displayed.

To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.

Socket created at: tcp://127.0.0.1:55555
Error using messenger
Error: ZMQ session not initialized

Error in matlabserver (line 30)
            messenger('respond', resp);

» 

I'd like to point out this exact snippet has been working flawlessly using pymatbridge-0.2 and the 'old' communication protocol.

I don't know if this is an issue of Windows or my build -- can pelase someone on a different OS try to replicate this behaviour?
Thanks!

EDIT: This seems to be due to the clear all; which seems to kill the matlabserver. I modified the issue title accordingly

@bs448c bs448c changed the title messenger / ZMQ session error using 'magic' messenger / ZMQ session error upon "Matlab clear all" using 'magic' May 15, 2014
@arokem
Copy link
Owner

arokem commented May 15, 2014

I'm sorry that this has been so difficult to get up and running. I can
replicate this error, and I will start looking into it. It's not obvious to
me what exactly is going on, but I do have a 5-hour flight just ahead of
me, so I will take a look.

On Thu, May 15, 2014 at 3:15 AM, bs448c notifications@github.com wrote:

As outlined in #56https://github.com/arokem/python-matlab-bridge/pull/56and
#69 #69 I manage
to build pymatbridge-0.3-dev under WIndows 8.1. I can start the
matlabserver and pass back and forth variables between MATLAB and my
iPython notebook (Anaconda 1.9.1, Python 2.7.6) using 'magic' (the x=x+1and
a=[1,2,3]

%%matlab -i a -o b,c
b = a + 3
c = b + 3

sort of examples)

However when trying to port a more complex example,

%%matlab -o x,xf

%Author: Osama Ullah Khan,
% Phd Student, University of Michigan-Ann Arbor.
% Email: oukhan@umich.edu
% Version: 1.0
%
%This code demonstrate compressive sensing example. In this
%example the signal is sparse in frequency domain and random samples
%are taken in time domain.

close all;
clear all;

%setup path for the subdirectories of l1magic
path(path, 'C:\MATLAB\R2013a\l1magic\Optimization');
path(path, 'C:\MATLAB\R2013a\l1magic\Data');

%length of the signal
N=1024;

%Number of random observations to take
K=256;

%Discrete frequency of two sinusoids in the input signal
k1=29;
k2=59;
k3=109;

n=0:N-1;

%Sparse signal in frequency domain.
x=sin(2_pi_(k1/N)n)+sin(2_pi(k2/N)n)+sin(2_pi(k3/N)*n);

xf=abs(fft(x));

my matlabserver fails:

MATLAB is running in headless mode. Figure windows will not be displayed.

To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.

Socket created at: tcp://127.0.0.1:55555
Error using messenger
Error: ZMQ session not initialized

Error in matlabserver (line 30)
messenger('respond', resp);

»

I'd like to point out this exact snippet has been working flawlessly using
pymatbridge-0.2 and the 'old' communication protocol.

I don't know if this is an issue of Windows or my build -- can pelase
someone on a different OS try to replicate this behaviour?
Thanks!


Reply to this email directly or view it on GitHubhttps://github.com//issues/70
.

@bs448c
Copy link
Author

bs448c commented May 15, 2014

glad that it's probably not due to my messenger build, then .. and thanks for looking into it. Again I don't think a sensible use case the clear all; is needed but still better to see what's going on

@arokem
Copy link
Owner

arokem commented May 16, 2014

It's definitely that clear all that is causing the trouble. There's
probably a way to circumvent that, but it would require some kind of hack.
For now, I propose removing the call to clear all.

On Thu, May 15, 2014 at 8:58 AM, bs448c notifications@github.com wrote:

glad that it's probably not due to my messenger build, then .. and
thanks for looking into it. Again I don't think a sensible use case the clear
all; is needed but still better to see what's going on


Reply to this email directly or view it on GitHubhttps://github.com//issues/70#issuecomment-43228635
.

@blink1073
Copy link
Collaborator

I think what's happening is clear all is removing variables used by matlabserver

@blink1073
Copy link
Collaborator

Specifically, it is clearing the initialized flag used here based on the error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants