フィルターのクリア

Making subplots by reading many files in Matlab

2 ビュー (過去 30 日間)
Ivan Mich
Ivan Mich 2019 年 9 月 27 日
コメント済み: Adam 2019 年 9 月 28 日
Hello,
I have a question about making subplots in Matab by reading many files in Matlab. First of all, I have a code who reads many .txt files that have my data.
I have files like these: A_ac_s001.txt , A_ac_s002.txt, A_ac_s003.txt ,..., A_ac_s100.txt
and
A_bc_s001.txt, A_bc_s002.txt,...., A_bc_s100.txt .
I have created one loop in order to read the first "team" of my data files and one loop in order to read the second "team" of my data files.
S = dir('A_ac*.txt');
for k = 1:numel(S)
S(k).name
end
S = dir('A_bb*.txt');
for k = 1:numel(S)
S(k).name
end
I would like to create a subplot which will create 2 plots for the first two files of each team with the command subplot(1,2,1) and subplot(1,2,2). But it doesn't work , because the result are two figures. Also I would like the title to be changing for every figure plot( I mean following the loop of my data).
Could anyone help me?
  6 件のコメント
Ivan Mich
Ivan Mich 2019 年 9 月 27 日
Excuse me but i dont understand the hFig you use in the command.
Adam
Adam 2019 年 9 月 28 日
It's just a variable name I usually use for a figure handle returned when you create a figure.

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

回答 (2 件)

Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro 2019 年 9 月 27 日
Perhaps it is not working because other problems:
subtitle('%%%%%%%'N1')
The title of a subplot is still title and the argument should be a string, if N1 is a number this would go like this
title(strcat('%%%%%%%',num2str(N1)))
  1 件のコメント
Ivan Mich
Ivan Mich 2019 年 9 月 27 日
I want the title of the first plot to be "Number 001" for example. The number of the second plot to be "Number 002". Imean i would like the title to be change according to the loop

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


Constantino Carlos Reyes-Aldasoro
Constantino Carlos Reyes-Aldasoro 2019 年 9 月 27 日
Ok in that case you will have something like
>> for k=1:9
name = strcat('Number_00',num2str(k))
end
name =
'Number_001'
name =
'Number_002'
name =
'Number_003'
name =
'Number_004'
name =
'Number_005'
name =
'Number_006'
name =
'Number_007'
name =
'Number_008'
name =
'Number_009'
That of course will only work up to 9, but you can use an "if" to have a different line if k>9.
  1 件のコメント
Adam
Adam 2019 年 9 月 28 日
If you are in a recent enough version of Matlab that has strings then
"Number_00" + ( 1:9 )
should work too.

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

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by