Plot Semilog/loglog data missing in plot

14 次查看(过去 30 天)
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

回答(2 个)

Voss
Voss 2022-4-21
"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 个评论
Venkatkumar M
Venkatkumar M 2022-4-25
still not working
Then how to make it work negative values for lolog plot
Voss
Voss 2022-4-25
"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"

请先登录,再进行评论。


Mitch Lautigar
Mitch Lautigar 2022-4-21
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 个评论
Venkatkumar M
Venkatkumar M 2022-4-25
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 2022-5-6
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by