bash - Missing something in the linux terminal after launching matlab from the command line -
i'm having weird behaviour when launching matlab command line in linux.
i've bash script in linux execute function in matlab command line , other operations custom functions written in c++ follows:
#!/bin/bash # prepare input data sure has not been written other test! matlab2011a -nodesktop -nosplash -r "prepare_data_matlab( 'a' ); quit" # launch c++ program ... # prepare more data matlab2011a -nodesktop -nosplash -r "prepare_data_matlab( 'b' ); quit" when script finished can not see i'm writing in terminal, although commands have effects. need reset terminal.
the fact works fine if launch matlab prepare_data_matlab( 'a' ) problem comes when execute function option prepare_data_matlab( 'b' ).
i have commented line line , found problem option b call function
dlmwrite(file_name, b, ' '); which not used in prepare_data_matlab( 'a' ).
so, how should execute matlab command line avoid behaviour? there known bug dlmwrite() function?
i'm using ubuntu 12.04 64 bits, gnu bash, versión 4.2.24(1)-release (x86_64-pc-linux-gnu) , matlab2011a.
edited: output generated prepare_data_matlab( 'a' ) 
the output generated prepare_data_matlab( 'b' ) 
edited: file_name created strcat(path_to_data,f); path_to_data = /tmp/ , f = data_out.txt. matrix b not displayed before or after.
the output terminal before or after matlab script generated bash script follow:
echo "#### select data workspace ####" matlab2011a -nodesktop -nosplash -r "prepare_data_matlab( 'b' ); quit"; echo "#### process data input in c++ programs ####" the matlab function select data workscape , save disk follows:
function [ ] = prepare_data_matlab( type ) if strcmp(type,'a') % load data workscape load ('workspace_with_my_arrays.mat', 'a'); % save data standalone variable save('/tmp/a.mat', 'a'); elseif strcmp(type,'b') % load data workscape load ('workspace_with_my_arrays.mat', 'b'); path_to_data = '/tmp/'; f = 'data_out.txt'; file_name = strcat(path_to_data,f); % save data txt file dlmwrite(file_name, b, ' '); end end edited: whos -file workspace_with_my_arrays.mat
name size bytes class attributes 610x340x103 170897600 double b 610x340x103 170897600 double p 610x340 1659200 double t1 38855x100 31084000 double t2 3921x2x100 6273600 double there more arrays in workspace load.
the prepare_data_matlab function same posted above argument error checking follow:
%% load data file % data saved in matlab variable or in txt if nargin ~= 1 error('use: prepare_data_matlab( [ | b ] )') end and following command:
cd /data/matlab; which executed after arguments error check in both cases (option aand option b), is, before if statement.
the problem not dlmwrite. seems bug in versions of matlab, reported in link.
the proposed solution (if have buggy version of matlab) use nohup:
nohup matlab -nodesktop -nosplash -r ........... update: per @amro 's suggestion, @pqb reported problem mathworks support. response was:
the problem known issue in versions prior r2012a. run matlab under different shell. example, neither tcsh or zsh have issue.
old answer: problem not dlmwrite, the content of matrix. furthermore, unless file_name points stdout (e.g., file_name='/dev/stdout';), dlmwrite function not write screen , not mess terminal. either file_name points stdout or displaying matrix b right before (or after) dlmwrite call.
in case, problem contents of matrix b (see strange characters in output). need fix problem matrix b. perhaps method using read input data faulty.
Comments
Post a Comment