Wrong axis scale on plot when using sqrt

Hello guys,
I am trying to see these plot, but when i use the square root on Y axis, my plot doesnt show properly the data, he dont do change his axis automatic, only show the data when i dont use squase root, and i dont know why.
% Imported data
set(gcf, 'Visible','off'); % turns current figure "off"
set(0, 'DefaultFigureVisible','off'); % all subsequent figures "off"
kC1=[
0.000 -00.1169E-09
-0.100 -00.1367E-09
-0.200 -00.1348E-09
-0.300 -00.1390E-09
-0.400 -00.1436E-09
-0.500 -00.1504E-09
-0.600 -00.1595E-09
-0.700 -00.1708E-09
-0.800 -00.1872E-09
-0.900 -00.2085E-09
-1.000 -00.2355E-09
-1.100 -00.2686E-09
-1.200 -00.3095E-09
-1.300 -00.3533E-09
-1.400 -00.4076E-09
-1.500 -00.4702E-09
-1.600 -00.5477E-09
-1.700 -00.6392E-09
-1.800 -00.7473E-09
-1.900 -00.8695E-09
-2.000 -01.0096E-09
-2.100 -01.1606E-09
-2.200 -01.3258E-09
-2.300 -01.5029E-09
-2.400 -01.6870E-09
-2.500 -01.8784E-09
-2.600 -02.0757E-09
-2.700 -02.2754E-09
-2.800 -02.4786E-09
-2.900 -02.6829E-09
-3.000 -02.8866E-09
-3.100 -03.0918E-09
-3.200 -03.2991E-09
-3.300 -03.5086E-09
-3.400 -03.7128E-09
-3.500 -03.9205E-09
-3.600 -04.1254E-09
-3.700 -04.3283E-09
-3.800 -04.5317E-09
-3.900 -04.7324E-09
-4.000 -04.9373E-09
-4.100 -05.1375E-09
-4.200 -05.3333E-09
-4.300 -05.5360E-09
-4.400 -05.7326E-09
-4.500 -05.9295E-09
-4.600 -06.1273E-09
-4.700 -06.3270E-09
-4.800 -06.5270E-09
-4.900 -06.7258E-09
-5.000 -06.9226E-09
];
VC1=kC1(:,1);
IC1=kC1(:,2);
plot(VC1,IC1);
xlabel('Gate Voltage Vg (V)');
ylabel('Drain-Source Current (A)');
title('422.21 OSC8 INV1 BIG');
% Figure and plot
figure('units','normalized','outerposition', [0 0 1 1]);
plot(kC1(:,1),sqrt(kC1(:,2)),'LineWidth',1);
set(gcf, 'Visible','on'); % turns current figure "on"
set(0, 'DefaultFigureVisible','on'); % all subsequent figures "on"
% Axis FTS norm for articles
xlabel('$V_g (V)$','Interpreter','latex','fontsize', 20,'FontWeight','bold');
ylabel('$\sqrt{ I_{DS} (A)}$','Interpreter','latex','fontsize', 20,'FontWeight','bold');
axis('square');
set(gcf, 'color','w');
% Color the curves to black
set(0, 'DefaultAxesColorOrder', [0 0 0] ,'DefaultAxesLineStyleOrder','-');
set(gca, 'FontSize',20);
Anyone knows why?

 Risposta accettata

The reason is that your ‘kCl’ data are all negative, so the square roots are all going to be pure imaginary.
See if:
plot(kC1(:,1),imag(sqrt(kC1(:,2))),'LineWidth',1);
produces the plot you want. Note that you will likely have to mention in your plot (or somewhere in your paper) that you are plotting the imaginary results of the square root operation on your ‘IC1’ variable (what ‘kCl(:,2)’ actually seems to be).

2 Commenti

ApolloPT
ApolloPT il 21 Gen 2015
Modificato: ApolloPT il 21 Gen 2015
omfg xD, since i was importing data from files(in these case i have put the data on the plot file), i didnt notice that i had negative values =/
Thanks Star Strider!
My pleasure!
Don’t worry — it happens to us all!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by