I have a csv file of data containing Target1, Target2 and VDD.There are x values and y values for each data. X values are scaler or real values But Y is complex values. For Target1 & Target2, there are no complex numbers as those are straight lines on the plot. But Y values of VDD are complex numbers. In csv data, Y has 2 parts real and complex parts. Those Y values of VDD are separeted with two cloumns of real values of complex numbers (real and imaginary) part.
So the plot of Target1, Target2 and VDD will be 2D and x axis points are same for all 3 parameters. I tried to plot but VDD is not plotting as it should be because the values in the csv file of y part of VDD is not matching in the plot as it should be and there is a warning message showing which I couldn't solve.
I also convert the data in logscle later.
Is there anyone who can help me out? Here is the CSV data. My MATLAB code and warning are given below.
MATLAB code:
% open data file
fid = fopen('parametric_Test-Copy.csv');
% Read data in from csv file
%readHeader = textscan(fid,'%s %s','Headerlines',0,'Delimiter',',');
readData = textscan(fid,'%f %f %f %f %f %f %f %f %f','Headerlines',1,'Delimiter',',');
% Extract data from readData
target1x = readData{1,1}(:,1);
target1y = readData{1,2}(:,1);
target2x = readData{1,4}(:,1);
target2y = readData{1,5}(:,1);
vddx = readData{1,7}(:,1);
vddy_Re = readData{1,8}(:,1);
vddy_Im = readData{1,9}(:,1);
vddz = complex(vddy_Re, vddy_Im);
% Plot Data
f1 = figure(1);
cla; hold on; grid on;
plot(target1x,target1y,'r-');
hold on;
plot(target2x,target2y,'b-');
hold on;
plot(vddx,vddz,'g-');
%set(gca,'yscale','log');
%set(gca,'xscale','log');
%xlim([0 3*10^9])
The warning:
Warning: Imaginary parts of complex X and/or Y arguments ignored In parametric_Test (line 26)
You need to define a criteria for the complex numbers to be greater or smaller than another. One way would be to ignore the imaginary parts (which MATLAB does by default). Or you can take modulus/complex magnitude by using abs
. Another way is to use the lexicographic order.
Read this post from math.stackexchange.com for more insight.
If you want to use the first approach (i.e. ignoring imaginary parts), use real
to avoid the warning message. Turning off the warning message altogether would not be a good idea in my opinion but you can do this using:
warning('off','MATLAB:plot:IgnoreImaginaryXYPart');
You can turn it on again by:
warning('on','MATLAB:plot:IgnoreImaginaryXYPart');
Read Suppress Warnings from the documentation for more details on this.
Implementing two of the approaches:
So if you use real
with vddz
vector i.e. real(vddz)
while plotting i.e.
plot(vddx,real(vddz),'g-');
or if you turn the warning off (or doesn't turn it off), you'd get (what you already are getting):
Since you believe that the above plot is incorrect. So it is evident that you would want to use some other criteria for comparison of the complex numbers. Using abs
with vddz
did the trick for you as confirmed by you in the comment i.e.
plot(vddx,abs(vddz),'g-');
which gives:
P.S It has nothing to do with the logarithmic scale.