MATLAB: Memory leak from waveform plotting at high frequency

frequencymemorysignal processing

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)

Best Answer

I don’t see the problem.
f = (200 : 0.5 : 245)*1E+6;
t = 0 : 0.01 : 1;
y = sin (2 * pi .* f(:) * t);
whos y
Name Size Bytes Class Attributes
y 91x101 73528 double
A 73.528 kB array isn’t that large.