フィルターのクリア

Plot Semilog/loglog data missing in plot

13 ビュー (過去 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 Center および File Exchange2-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