Note that there are some explanatory texts on larger screens.

plurals
  1. POMissing something in the linux terminal after launching matlab from the command line
    primarykey
    data
    text
    <p>I'm having a weird behaviour when launching matlab from the command line in linux. </p> <p>I've a bash script in linux that execute a function in matlab from the command line and does other operations with custom functions written in C++ as follows:</p> <pre><code>#!/bin/bash # prepare input data just to be sure it has not been written by 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" </code></pre> <p>When the script is finished I can not see what I'm writing in the terminal, although the commands have effects. I need to <code>reset</code> the terminal.</p> <p>The fact is that everything works fine if I only launch matlab with the <code>prepare_data_matlab( 'A' )</code> but the problem comes when I execute the function with option <code>prepare_data_matlab( 'B' )</code>.</p> <p>I have commented line by line and found that the problem is with option <code>B</code> that call the function </p> <pre><code>dlmwrite(file_name, B, ' '); </code></pre> <p>which is not used in <code>prepare_data_matlab( 'A' )</code>.</p> <p>So, how should I execute the matlab from the command line to avoid this behaviour? Is there a known bug with the <code>dlmwrite()</code> function?</p> <p>I'm using <em>Ubuntu 12.04</em> 64 bits, GNU <em>bash</em>, versión <em>4.2.24(1)-release</em> (x86_64-pc-linux-gnu) and <em>matlab2011a</em>.</p> <p><strong>EDITED:</strong> The output generated for <code>prepare_data_matlab( 'A' )</code> is <img src="https://i.stack.imgur.com/kueZK.png" alt="enter image description here"></p> <p>The output generated for <code>prepare_data_matlab( 'B' )</code> is <img src="https://i.stack.imgur.com/lIbQI.png" alt="enter image description here"></p> <p><strong>EDITED:</strong> <code>file_name</code> is created as <code>strcat(path_to_data,f);</code> where <code>path_to_data = /tmp/</code> and <code>f = data_out.txt</code>. Matrix <code>B</code> is not displayed before or after. </p> <p>The only output to the terminal before or after the MATLAB script is generated from the bash script as follow:</p> <pre><code>echo "#### SELECT DATA FROM WORKSPACE ####" matlab2011a -nodesktop -nosplash -r "prepare_data_matlab( 'B' ); quit"; echo "#### Process Data as input in a C++ programs ####" </code></pre> <p>The MATLAB function select data from the workscape and save it to disk as follows:</p> <pre><code>function [ ] = prepare_data_matlab( type ) if strcmp(type,'A') % load data from workscape load ('workspace_with_my_arrays.mat', 'A'); % save data as a standalone variable save('/tmp/A.mat', 'A'); elseif strcmp(type,'B') % load data from 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 as a txt file dlmwrite(file_name, B, ' '); end end </code></pre> <p><strong>EDITED:</strong> whos -file workspace_with_my_arrays.mat</p> <pre><code>Name Size Bytes Class Attributes A 610x340x103 170897600 double B 610x340x103 170897600 double P 610x340 1659200 double t1 38855x100 31084000 double t2 3921x2x100 6273600 double </code></pre> <p>There are more arrays in the workspace but those are which I load. </p> <p>The <code>prepare_data_matlab</code> function is the same as posted above but with an argument error checking as follow:</p> <pre><code>%% Load data from file % Data is saved in a MATLAB variable or in TXT if nargin ~= 1 error('Use: prepare_data_matlab( [ A | B ] )') end </code></pre> <p>and the following command:</p> <pre><code>cd /data/matlab; </code></pre> <p>which is executed after the arguments error check in both cases (option <code>A</code>and option <code>B</code>), that is, before the <code>if</code> statement.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload