Borrar filtros
Borrar filtros

Choosing not number elements from matrix to use in title figures and plots

1 visualización (últimos 30 días)
I want to use a list of names to put in titles of plots or figures.
This is the matrix and the code in my try.
sis = 1; % This defines which element of the sismo matrix element to display
sismo = {'1966 EW Lima' ; '1966 NS Lima'; ...
'1970 EW Ancash'; '1970 NS Ancash';...
'1974 EW Enero Lima'; '1974 NS Enero Lima';...
'1974 EW Octubre Lima'; '1974 NS Octubre Lima';...
'2001 EW Arequipa'; '2001 NS Arequipa';...
'2007 EW Ica Callao'; '2007 NS Ica Callao'; ...
'2007 EW Ica'; '2007 NS Ica'};
sismo = sismo(sis);
figure(sprintf('Numero %s',sismo))

Respuesta aceptada

ANKUR KUMAR
ANKUR KUMAR el 29 de Sept. de 2018
Editada: ANKUR KUMAR el 29 de Sept. de 2018
isletter gives the logical values where ever the letter is in your string. Use this is extract only letters and put this as title
clc
clear
sismo = {'1966 EW Lima' ; '1966 NS Lima'; ...
'1970 EW Ancash'; '1970 NS Ancash';...
'1974 EW Enero Lima'; '1974 NS Enero Lima';...
'1974 EW Octubre Lima'; '1974 NS Octubre Lima';...
'2001 EW Arequipa'; '2001 NS Arequipa';...
'2007 EW Ica Callao'; '2007 NS Ica Callao'; ...
'2007 EW Ica'; '2007 NS Ica'};
for i=1:length(sismo)
subplot(3,5,i)
plot(magic(2))
% title(char(regexp(sismo{i},'\d*','Match'))) %title as only numbers
title(sismo{i}(isletter(sismo{i}))) %title as only letters
end
  4 comentarios
ANKUR KUMAR
ANKUR KUMAR el 29 de Sept. de 2018
For figure name, try this,
for i=1:length(sismo)
figure('Name',sismo{i}(isletter(sismo{i})))
plot(magic(2))
% title(char(regexp(sismo{i},'\d*','Match'))) %title as only numbers
% title(sismo{i}(isletter(sismo{i}))) %title as only letters
title(sismo{i}(union(find(isletter(sismo{i})),strfind(sismo{i},' ')))) %is you wish space too in your title
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Visual Exploration en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by