# how can I plot a power spectrum for 150 range bins with 512 fft points [closed]

This is my code for plotting... However when I plot my spectrum data using this code, it is showing only 1 row. How can I plot all 150 rows? Can anyone help me to solve this?

 for i=1:length(dataheader.nrgb)
plot(freq,arraydata(i,:)+height(i))
end


By default, matlab's plot command clears the plot area before drawing the new curve.

To prevent this, and allow multiple curves to appear on the same figure, you can activate the hold mode:

hold off; % 1st plot will clear figure
for i = 1:length(data header.nrgb)
plot(freq,arraydata(i,:)+height(I));
hold on; % set hold mode for subsequent figures
end


Alternatively you can stack multiple copies of freq and the plot command will draw one curve per column. Since your data is organized by rows, you'll need to transpose your data matrix:

% just make sure freq & height are column vectors. This may not be necessary if they already are.
if size(freq,1) < size(freq,2)
freq = transpose(freq);
end
if size(height,1) < size(height,2)
height = transpose (height);
end

% plot one curve per column on same figure
N = length(data header.nrgb);
plot(repmat(freq,1,N), transpose (arraydata)+repmat(height,1,N))