Effacer les filtres
Effacer les filtres

Use the index in a FOR loop for a string

9 vues (au cours des 30 derniers jours)
Antonio
Antonio le 10 Avr 2017
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.

Réponse acceptée

Stephen23
Stephen23 le 11 Avr 2017
@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:

Plus de réponses (1)

John Osborne
John Osborne le 10 Avr 2017
Modifié(e) : John Osborne le 10 Avr 2017
Try
figure(i)
%plotting commands
title(['Hurricane ' num2str(i)])
  3 commentaires
Stephen23
Stephen23 le 11 Avr 2017
Modifié(e) : Stephen23 le 11 Avr 2017
@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 le 11 Avr 2017
@Stephen Cobeldick: Thanks for your great answer :)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by