Hello,
I am trying to plot 2 graphs in the same figure, but I am having a problem as the two datasets contain different number of points. How can I plot the graphs in the same figure but in different plots. That is, plot a will have (col 1, col2), plot 2 will have (col3, col4).
Here is what I have so far:
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', 4); buffer = buffer'; if i == 0; v = buffer; else v = vertcat(v,buffer); end i = i + 1;end% Frequency vector
freq1 = v(:,1);freq2 = v(:,3);% Phase noise vector
spectrum1 = v(:,2);spectrum2 = v(:,4);subplot(1, 2, 1);plot(freq1,spectrum1); ax.XTick = [380.0145:380.0345:.1]; grid on; axis([380.0145 380.0345 -130 -10]);title('Silent Carrier (No Modulation)');xlabel('Frequency (MHz)'); ylabel('Amplitude');subplot(1, 2, 2);semilogx(freq2,spectrum2)grid on; title('SSB Spectrum with 1kHz Tone');xlabel('Frequency Offset (Hz)'); ylabel('Phase Noise (dBc/Hz)');return
Best Answer