Plot Semilog/loglog data missing in plot

조회 수: 7 (최근 30일)
Venkatkumar M
Venkatkumar M 2022년 4월 21일
댓글: Mitch Lautigar 2022년 5월 6일
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에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by