How to plot phase graph from csv with real and imaginary values?

11 views (last 30 days)
Hi I was wondering if anyone could help with me plotting data from a csv file. I have 3 columns, the first being frequency from 1ghz-2ghz, the second column being real S11, and the third being imaginary S11. I obtained the data from a network analyzer and would like to get that graph that I saw from the network analyzer and put that into matlab. I first imported that data into matlab then set each column to a variable so:
x=freq;
y=real;
z=imag;
plot(x,[y,z])
Any help would be great thanks!
  1 Comment
Jakub Panuska
Jakub Panuska on 24 Feb 2016
you can use csvread to read your data into matlab...be aware about your delimiter in csv
data=csvread('myFile.dat') %you should use full path to your directory or set the directory in matlab current folder window
freq=data(:,1); %read data in column (specify your column) 1 into freq
real=data(:,2); %read data in column (specify your column) 2 into real
imag=data(:,3); %read data in column (specify your column) 3 into imag
phase=atan(imag/real); %phase angle

Sign in to comment.

Answers (1)

MHN
MHN on 24 Feb 2016
Edited: MHN on 25 Feb 2016
It depends on what would you like to plot. But first you must define them as complex number for Matlab:
z = complex(real, imag);
Now you can plot them based on what you want to plot. for example plot the real part based on frequency, plot the imaginary part based on frequency, plot the absolute value based on frequency, the phase based on frequency, and so on.

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!