Help with code needed - sampling

1 回表示 (過去 30 日間)
Tom
Tom 2012 年 1 月 25 日
Help with code needed - sampling
I have an equation of a signal, and I'm supposed to be making a PDF graph of it - but I can't use any of Matlab's inbuilt functions.
I'm only half way through the code - I need a 2-D matrix and I can't get it working.
close all
clear all
freq = 220;
ar = 2;
M = 10;
n = linspace(0,M-1,M);
An = 3+n*ar/M;
N = 10;
T = 1;
j = linspace(0,N-1,N);
tj = j*T/N;
xj = 4-cos(2*pi.*tj);
fnj = zeros(M,N);
for g = 1:length(An)
for h = 1:length(xj)
if An <= xj <= (An+1)
fnj(g,h) = 1;
else
fnj(g,h) = 0;
end
end
end
What I want if for the matrix 'fnj' to be made up of 0s and 1s - so for each amplitude point, a number of samples can be totalled - giving a spread of data which can then be plotted to give a PDF.

採用された回答

Dr. Seis
Dr. Seis 2012 年 1 月 25 日
One change to make:
An <= xj <= (An+1)
should be split up
(An <= xj) && (xj <= (An+1))

その他の回答 (1 件)

Tom
Tom 2012 年 1 月 25 日
Nice one

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by