フィルターのクリア

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

1 回表示 (過去 30 日間)
Isai Fernandez
Isai Fernandez 2018 年 9 月 29 日
コメント済み: ANKUR KUMAR 2018 年 9 月 29 日
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))

採用された回答

ANKUR KUMAR
ANKUR KUMAR 2018 年 9 月 29 日
編集済み: ANKUR KUMAR 2018 年 9 月 29 日
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 件のコメント
ANKUR KUMAR
ANKUR KUMAR 2018 年 9 月 29 日
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
ANKUR KUMAR
ANKUR KUMAR 2018 年 9 月 29 日

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by