Add a decade plots to graph
10 views (last 30 days)
Show older comments
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/148713/image.png)
How do I go about doing this?
Thanks.
0 Comments
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!