필터 지우기
필터 지우기

To Save contourf sequentially in loop according to input filename

조회 수: 1 (최근 30일)
Bhowmik.U
Bhowmik.U 2019년 2월 5일
댓글: Bhowmik.U 2019년 2월 5일
Hello,
I wish to save contourf sequentially in for loop according to input filename, but it throws error : "Simulink object array must be avector"
My code:
fil=dir('*.h5');
for K=1:numel(fil)
g=fil(K).name; s1=num2str(g(7:11)); %s1 is my file name which changes in each loop
(functions)
im=contourf(x,y,z)
saveas(im,strcat(s1,'.fig'));
saveas(im,strcat(s1,'.png'));
end
I guess I am at lack of understanding the issue...any help shall be welcome !

채택된 답변

KSSV
KSSV 2019년 2월 5일
편집: KSSV 2019년 2월 5일
Note that im will be matrix. YOu cannot save like that.
Try this:
fil=dir('*.h5');
for K=1:numel(fil)
g=fil(K).name; s1=num2str(g(7:11)); %s1 is my file name which changes in each loop
(functions)
im=contourf(x,y,z)
saveas(gcf,strcat(s1,'.fig'));
saveas(gcf,strcat(s1,'.png'));
end
  댓글 수: 5
KSSV
KSSV 2019년 2월 5일
Use hold off when the plotting thing gets over...
Bhowmik.U
Bhowmik.U 2019년 2월 5일
Many thanks Sir! No words to express my gratitude...

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by