필터 지우기
필터 지우기

Use the index in a FOR loop for a string

조회 수: 9 (최근 30일)
Antonio
Antonio 2017년 4월 10일
답변: Stephen23 2017년 4월 11일
How do I make 50 plots (in separate figures) using the following format:
for i = 1:50
figure('name','Hurricane "i"')
scatter(x,y,10,z"i");
title('Hurricane "i"');
end
e.g. I want graphs like scatter(x,y,10,z36) with the title of "Hurricane 36". Thanks for your help in advance.

채택된 답변

Stephen23
Stephen23 2017년 4월 11일
@Mamali: you should put your data into one array (either an matrix, and ND array, or a cell array) and using indexing. Do not try to access variable names dynamically:

추가 답변 (1개)

John Osborne
John Osborne 2017년 4월 10일
편집: John Osborne 2017년 4월 10일
Try
figure(i)
%plotting commands
title(['Hurricane ' num2str(i)])
  댓글 수: 3
Stephen23
Stephen23 2017년 4월 11일
편집: Stephen23 2017년 4월 11일
@Mamali: you should put your data into one array (either an matrix, and ND array, or a cell array) and using indexing. Do not try to access variable names dynamically:
Antonio
Antonio 2017년 4월 11일
@Stephen Cobeldick: Thanks for your great answer :)

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by