what am I doing wrong?

I have a doubt in the representation of a discrete signal. With help from Azzi Abdelmalek I wrote the following code
p=-5:0.0001:5;
%Input number
Imp=input('number pulse:\n');
out=zeros(1,numel(p));
for x = 1:Imp
%input amplification
a(x)=input('amplification pulse:\n');
%step position
p(x)=input('initial Position:\n');
out=out+a(x)*heaviside(p-p(x));
stem(p,out);
end
xlabel('Position');
ylabel('Amplification');
title('graph');
grid on;
but the representation is wrong,what am I doing wrong?
The signal must be a sum of impulses and the user to choose the number of pulses and each pulse amplitude and choose your position, as follows: x (n) = a1  (n-n1) a2 +  (n-n2) + ...

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 11 月 6 日

0 投票

You are using p to represent the locations being sampled at, and you are using p(x) to represent the pulse positions, but p(x) is the same vector as vector p . You should be using two different names for the two different items.

3 件のコメント

Manuel
Manuel 2013 年 11 月 6 日
the problem is the same
Image Analyst
Image Analyst 2013 年 11 月 6 日
Please update your code with the variables that have the new names that Walter suggested. You said you made the changes he suggested, but we don't want to make recommendations on code we haven't seen.
Manuel
Manuel 2013 年 11 月 7 日
if true
p=-5:0.0001:5;
%Input number
Imp=input('number pulse:\n');
out=zeros(1,numel(p));
for x = 1:Imp
%input amplification
a(x)=input('amplification pulse:\n');
%step position
p1(x)=input('initial Position:\n');
out=out+a(x)*heaviside(p-p1(x));
stem(p,out);
end
xlabel('Position');
ylabel('Amplification');
title('graph');
grid on;
end

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

Manuel
Manuel 2013 年 11 月 7 日

0 投票

I do not understand what I'm doing wrong

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

タグ

質問済み:

2013 年 11 月 6 日

回答済み:

2013 年 11 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by