Plot Semilog/loglog data missing in plot

8 views (last 30 days)
Hi,
I am Plotting attched csv in semilogx and loglog plot.
In semilogx plot is 20hz to 30MHz
but in loglog i am not able to plot from 20Hz but it is ploting from 1Mhz.
I want plot to be in loglog from 20hz to 30Mhz
Could anyone please help to resolve issue?
s=xlsread('2.2 uF.CSV');
freq=s(:,1);
x=s(:,3);
figure()
loglog(freq,x)
grid on
figure()
semilogx(freq,x)
grid on

Answers (2)

Voss
Voss on 21 Apr 2022
"I want plot to be in loglog from 20hz to 30Mhz"
That's easy enough to acheive by setting the x-limits of the log-log plot:
figure()
loglog(freq,x)
grid on
xlim([20 30e6])
(And if you do that probably you want to do the same for the semi-log plot.)
However, that's not going to make the "missing" data show up. The impedance values you're plotting are negative at low frequencies. You can't plot a negative number on a log y-scale because the logarithm of a negative number is a complex number. So those negative values are never going to show up on the log-log plot.
  2 Comments
Venkatkumar M
Venkatkumar M on 25 Apr 2022
still not working
Then how to make it work negative values for lolog plot
Voss
Voss on 25 Apr 2022
"how to make it work negative values for lolog plot"
The answer to that question is the same as the answer to "where are the complex numbers along the real number line?"
To reiterate my answer: "those negative values are never going to show up on the log-log plot"

Sign in to comment.


Mitch Lautigar
Mitch Lautigar on 21 Apr 2022
I believe the issue you are seeing is that you cannot take the log of a negative number. Since the majority of your data is negative, that is why you are seeing this issue. I also recommend using "readtable" and "table2array" to read in your data since your indexing using xlsread would read in the first few rows of the spreadsheet which aren't needed.
  2 Comments
Venkatkumar M
Venkatkumar M on 25 Apr 2022
clear all;
clc;
s=readtable('2.2 uF.CSV');
freq=s(:,1);
r=s(:,2);
x=s(:,3);
Error using readtable (line 216)
Reading failed at line 1607. All lines of a text file must have the same number of delimiters. Line 1607 has 0 delimiters, while
preceding lines have 2.
Note: readtable detected the following parameters:
'Delimiter', ',', 'HeaderLines', 4, 'ReadVariableNames', true, 'Format', '%f%f%f'
Still error could you please help me resolve this?
Mitch Lautigar
Mitch Lautigar on 6 May 2022
The answer you are looking for has been provided. You have negative values which you are trying to take the log for. If you use "real()" and "imag()" you might have some luck achieving some plots. But you mathematically CANNOT take the log of a negative number.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!