Using unix within MATLAB

조회 수: 1 (최근 30일)
Neil Bhattacharjee
Neil Bhattacharjee 2016년 7월 5일
댓글: Walter Roberson 2016년 7월 6일
I know there are several questions similar to this one, but none seem to be applicable in my scenario.
I want to convert a pdf (or eps) file from my matlab code into a png, using the downloadable software called ImageMagick.
In my command terminal, in order to execute this file format switch, I must type
convert file_name.pdf new_file_name_with_new_format.png
then, if I wanted to display it, (which I do), I go
display new_file_name_with_new_format.png
This works fine in the terminal window, but how can I do this in matlab? What specific syntax should I use.
I've tried some stuff with !, but to no solution.
Thanks,
Gauss.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 7월 6일
oldname = 'file_name.pdf';
newname = 'new_file_name_with_new_format.png'
command = sprintf('convert ''%s'' ''%s''', oldname, newname);
system(command);
command = sprintf('display ''%s''', newname);
system(command)
  댓글 수: 2
Neil Bhattacharjee
Neil Bhattacharjee 2016년 7월 6일
Thanks for your reply.
I'm getting the problem
/bin/bash: convert: command not found
Could this possible be due to the location in which convert and display are in?
They are stored in
/opt/local/bin/convert
and
/opt/local/bin/display
Do I have to reference this somehow in my matlab code?
Thanks!
Walter Roberson
Walter Roberson 2016년 7월 6일
command = sprintf('/opt/local/bin/convert ''%s'' ''%s''', oldname, newname);

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

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by