필터 지우기
필터 지우기

using predefined string for savefig

조회 수: 4 (최근 30일)
Jairo
Jairo 2014년 3월 27일
댓글: Joseph Cheng 2014년 3월 28일
Im new to matlab so sorry about this.
I am trying to save a figure within a subroutine. The string to be used in the file name already exists. I know i could simply type it in but the filename depends on the parameters used in the particular data set; and there are 150 data sets.
the comands are as follows
fileparams = ['50psi_10A_Sawtooth_05Hz']
savefig(fileparams)
I get an error: "Undefined function or method 'savefig' for input arguments of type 'char'."
I have tried changing it to a cell string array and i get: "Undefined function or method 'savefig' for input arguments of type 'cell'."
How can i resolve this?
Jairo

채택된 답변

Marta Salas
Marta Salas 2014년 3월 27일
fileparams = ['50psi_10A_Sawtooth_05Hz']
filename = [fileparams '.fig']
print(filename)
  댓글 수: 7
Marta Salas
Marta Salas 2014년 3월 28일
Try this one instead of print
saveas(gcf,filename)
Jairo
Jairo 2014년 3월 28일
There it is! thanks again.

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

추가 답변 (1개)

Joseph Cheng
Joseph Cheng 2014년 3월 27일
What you have should work. The only thing that could get in the way is if you have a user-defined function that is also called savefig() within the search path of Matlab. Try
edit savefig
if it asks if you want to create it then you do not have another copy somewhere. If you are able to open it and "edit" it (i wouldn't edit it) then it might not be the same MATLAB savefig.
  댓글 수: 4
Jairo
Jairo 2014년 3월 28일
I am currently talking to Matlab tech to see what the problem is.
Joseph Cheng
Joseph Cheng 2014년 3월 28일
you should also look to see if the "set paths" are correct. (Files menu->Set paths) see if there are many many entries form C:\programfiles\Matlab\version\tool boxes etc.

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

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by