Dynamic file name with saveas() function
이전 댓글 표시
Hi,
I am using matlab into a labview program and I need to save figures. I have a variable which contain the name I want to use to save the file but I can't use this variable into the function:
fileName = strcat(numberOfBeams, 'RPM vs Volt');
saveas(gcf, [dirfig, fileName, 'png']);
The code gives an error... But it works if don't use the variable
saveas(gcf, [dirfig, 'RPM vs Volt TEST', 'png']);
Thanks a lot for your help !
댓글 수: 3
Walter Roberson
2012년 6월 26일
What does class(numberOfBeams) and size(numberOfBeams) and class(fileName) indicate ?
What is the error message?
My speculation is that the strcat() is producing a cell array.
Jean
2012년 6월 26일
Walter Roberson
2012년 6월 26일
What error message is being produced?
답변 (1개)
Image Analyst
2012년 6월 27일
Try this:
folder = dirfig;
baseFileName = sprintf('%d RPM vs Volt.png', numberOfBeams);
fullFileName = fullfile(folder, baseFileName);
saveas(gcf, fullFileName);
% Or even better:
export_fig(fullFileName);
% http://blogs.mathworks.com/pick/2010/05/28/creating-and-exporting-publication-quality-graphics/
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!