Plot vectors in cell array over for loop

12 ビュー (過去 30 日間)
skrowten_hermit
skrowten_hermit 2020 年 10 月 12 日
コメント済み: skrowten_hermit 2020 年 10 月 12 日
I have the following data structure (a cell array populated with vectors):
sigvecarray = {};
freqarray = {};
% Reading the audio files, getting the signal vector and the corresponding
for k = 1:numel(inputarray) % indices
curr_input = inputarray{k};
[y, Fs] = audioread(curr_input);
sigvecarray{k} = y;
freqarray{k} = Fs;
end
I'm trying to plot them over a for loop by using the following:
for k = 1:numel(sigvecarray)
plot(sigvecarray{k})
end
But I get only the fist vector plotted as my output. What could I be doing wrong here? Is it because the cell array is a row vector? If yes, how do I convert the cell array to a column vector from a row vector?

採用された回答

KSSV
KSSV 2020 年 10 月 12 日
figure
hold on
for k = 1:numel(sigvecarray)
plot(sigvecarray{k})
end
  5 件のコメント
skrowten_hermit
skrowten_hermit 2020 年 10 月 12 日
I had tried out subplots before. They seem to shrink the plots to fit the screen when I do:
for k = 1:numel(sigvecarray)
subplot(length(sigvecarray), 1, k)
plot(sigvecarray{k})
end
Is there a way to decide the size (in pixels for example) of each plot? Say 640x480 or something like that?
KSSV
KSSV 2020 年 10 月 12 日
Possible you need to set the size of whole figure etc....read the doc.

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

その他の回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 10 月 12 日
編集済み: Ameer Hamza 2020 年 10 月 12 日
hold on
will add new lines on the same axes without deleting old lines.
  3 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 10 月 12 日
You need to use the Position property of the axes object to change their size. An alternative might be to use
nexttile(): https://www.mathworks.com/help/matlab/ref/nexttile.html. Though I am not sure if there is a significant difference.
skrowten_hermit
skrowten_hermit 2020 年 10 月 12 日
Thanks. Looks promising. I'll definitely try nexttile().

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

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by