How can I control matlab from ubuntu terminal?

조회 수: 1 (최근 30일)
Paschalis Garouniatis
Paschalis Garouniatis 2017년 7월 30일
댓글: Walter Roberson 2017년 7월 31일
Hi everyone. I want to create a shell script which will identify a text file given from the user and then open matlab and extract data from within the text file. This is what I've done so far:
#!/bin/bash
read -p "Type desired file for data mining :" filename
echo "Selected file : $filename.txt"
cd Desktop/ocean_lab_data
vi $filename.txt
cd ../
cd ../
cd ../
cd ../
cd usr/local/MATLAB/R2016b/bin/
./matlab -nosplash -nodesktop
addpath(genpath('directory of the text file'));
A=importdata('$filename.txt');
My problem for now is that I can't pass the commands following "./matlab -no splash -nodesktop" into matlab. Any help will be much appreciated.

채택된 답변

Walter Roberson
Walter Roberson 2017년 7월 30일
Use the -r flag
./matlab -nosplash -nodesktop -r "addpath(genpath('directory of the text file')); A=importdata('$filename.txt');"
  댓글 수: 7
Paschalis Garouniatis
Paschalis Garouniatis 2017년 7월 31일
I tried it without the alias and it worked. Thanks a lot for your time Walter. If you have any suggestion for my previous comment please post it. Thnx again.
Walter Roberson
Walter Roberson 2017년 7월 31일
At the moment I cannot think of any reason why additional arguments would be ignored if alias was used.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by