Memory leak from waveform plotting at high frequency
이전 댓글 표시
Hi
I'm having problems with 16gb of RAM on my computer being taken up calculating the below.
I know its because of t and f, How do I code the sampling to be right at high frequencies such as 200-250 MHz so it plots at appropriate time intervals that is not taxing?
t = 0 : 0.01 : 1;
for f = 200000000 : 500000 : 250000000 % From 200 MHz to 245 MHz with 500 kHz increment
y(f,:) = sin (2 * pi .* f .* t);
end
figure(1)
plot(t,y)
figure(2)
%Also plot the sum of each waveform at each time interval t
plot(t, sum(y), ':r', 'LineWidth',2.5)
채택된 답변
추가 답변 (2개)
Walter Roberson
2017년 11월 5일
t = 0 : 0.01 : 1;
num_t = length(t);
fvals = 200000000 : 500000 : 250000000;
num_f = length(fvals);
y = zeros(num_f, num_t);
for f_idx = 1 : num_f % From 200 MHz to 245 MHz with 500 kHz increment
f = fvals(f_idx);
y(f_idx,:) = sin (2 * pi .* f .* t);
end
figure(1)
plot(t, y)
figure(2)
%Also plot the sum of each waveform at each time interval t
plot(t, sum(y), ':r', 'LineWidth',2.5)
You just happen to have the same number of f values as you have time steps. MATLAB creates one line per column, and your different columns correspond to increasing frequency. You need to think about whether you instead want to plot(t, y.') to have it show increasing time for each line.
Nathan Kennedy
2017년 11월 5일
편집: Nathan Kennedy
2017년 11월 5일
0 개 추천
댓글 수: 3
Star Strider
2017년 11월 5일
The aliasing problem can largely be eliminated using an appropriate magnitude for ‘t’.
This produces good results when substituted for the original vector:
t = linspace(0, 2E-8, 250);
This results from the wavelength calculation:
lambda = 1/250E+6;
producing a wavelength at the highest frequency of 4E-9 (seconds).
Nathan Kennedy
2017년 11월 5일
Star Strider
2017년 11월 5일
The frequency vector in my Fourier transform code is based on the time vector. If the time vector is not appropriate (my new time vector is appropriate) the frequency vector will be similarly affected.
I have to rely upon the information provided in your Question, and unless you state that there’s a problem with it, I assume it’s correct.
카테고리
도움말 센터 및 File Exchange에서 Pulsed Waveforms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!