I need to scale the axes of a convolution function after plotting successive convolutions of x with itself. How do I scale the x axis for each so it has the correct support and how do I scale the convolutions to show that they are density functions?

19 ビュー (過去 30 日間)
x=ones(1,20);
con0=conv(x,x);
con1=conv(x,con0);
figure(1);
plot(con0);
figure(2);
plot(con1);
Thanks in advance!
  2 件のコメント
Rik
Rik 2020 年 2 月 4 日
編集済み: Rik 2020 年 2 月 4 日
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.
After every convolution the number of elements changes. Is this intentional?
If you use plot with only one input it will use the index as the x-value, so if you want a different axis you can simply supply an x-scale that suits you.
By 'showing that they are density distributions' do you mean they should be scaled to an area of 1?
GS25
GS25 2020 年 2 月 4 日
Thanks for your assistance. I'll take a look for next time.
The change in number of elements is intentional, I want to convolve 10 times, what I posted was a sample for the first two.
Yes that is exactly it, I need to find a way to scale the plot to an area of 1.
Thank you Rik.

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

採用された回答

Rik
Rik 2020 年 2 月 4 日
Something like the code below should be close to what you want. Addapt as needed.
y=ones(1,20);
N=10;
output=cell(N,1);
output{1}=conv(y,y);
for n=2:N
output{n}=conv(y,output{n-1});
end
figure(1);clf(1)
%determine number of subplots
a=floor(sqrt(N));a=max(a,1);
b=ceil(N/a);
for n=1:N
subplot(a,b,n)
con=output{n};
x=linspace(0,1,numel(con));
con=con/trapz(x,con);%scale to unit area
plot(x,con);
title(sprintf('iteration %d',n))
axis([min(x) max(x) 0 5])
end

その他の回答 (0 件)

カテゴリ

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