Add a decade plots to graph
25 次查看(过去 30 天)
显示 更早的评论
From the attached simulated data file, I wanted to add decade plots as follows:
- 30 dB per decade from 100 to 3000
- 20 dB per decade from 3000 to 1000000
- Horizontal line from 1000000 to 40000000
Here is my code for the original data file:
% Select file
clear;
clc;
[FileName,PathName] = uigetfile('*.txt','Select data file');
fid = fopen( strcat(PathName,FileName) ,'rt' );
% Read the file and store into matrix v
i = 0;
v = [0 0];
while feof(fid) == 0
buffer = fscanf(fid, '%f', 2);
buffer = buffer';
if i == 0;
v = buffer;
else
v = vertcat(v,buffer);
end
i = i + 1;
end
% Frequency vector
freq = v(:,1);
% Phase noise vector
pnoise = v(:,2);
figure
semilogx(freq,pnoise); grid on; axis([100 40^5 -160 -70]);
title('Simulated Phase Noise');
xlabel('Offset Frequency (Hz)'); ylabel('Phase Noise (dBc/Hz)');
return
My end plot should look something like:
How do I go about doing this?
Thanks.
0 个评论
回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!