# in y axis i want 10^(-2000). can anyone plz help

27 ビュー (過去 30 日間)
Kasmita Devi 2024 年 5 月 21 日 7:20
コメント済み: Steven Lord 2024 年 5 月 21 日 15:10
set(gca, 'YScale', 'log')
ylim ([0 1e-308])
Instead of 1e-308 i want 1e-2000. how can i set the limit plz

サインインしてコメントする。

### 採用された回答

Hassaan 2024 年 5 月 21 日 8:35
Assummed use case may help:
clc; clear all; close all;
% Generate dummy frequency data
f = linspace(0, 1000, 1000); % Frequency vector from 0 to 1000 Hz
% Generate dummy PSD data with very small values
PSD = 10.^(-2000 + randn(1, 1000) * 10); % Generate PSD data around 10^(-2000)
% Rescale the PSD to avoid numerical underflow
scale_factor = 10^2000;
rescaled_PSD = PSD * scale_factor;
% Plot the rescaled PSD
figure;
plot(f, rescaled_PSD);
title('Power Spectrum Density');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency');
grid on;
% Set the y-axis to logarithmic scale
set(gca, 'YScale', 'log');
% Adjust y-axis tick labels to reflect the original scale
yticks = get(gca, 'YTick'); % Get current y-axis tick values
yticklabels = arrayfun(@(x) sprintf('10^{%d}', log10(x) - 2000), yticks, 'UniformOutput', false);
set(gca, 'YTickLabel', yticklabels);
% Set appropriate y-axis limits
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
• Technical Services and Consulting
• Embedded Systems | Firmware Developement | Simulations
• Electrical and Electronics Engineering
Feel free to contact me.
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
Kasmita Devi 2024 年 5 月 21 日 9:05
Thank you so much sir . it is working.

サインインしてコメントする。

### その他の回答 (1 件)

Walter Roberson 2024 年 5 月 21 日 7:33
1e-2000 would underflow to 0. You can only use such a number symbolically... but symbolic numbers cannot be used as limits.
You also cannot plot() such small numbers. I am not sure it is possible to fplot() them either.
Your best bet would be to rescale your numbers to something like 0 to 100 and then change your ytick labels to lie about the range.
##### 3 件のコメント1 件の古いコメントを表示1 件の古いコメントを非表示
Kasmita Devi 2024 年 5 月 21 日 7:56
Actually, I am getting my error 10^(-2000) which is very less and that is superior result as compared to existing results. so i want to plot that in y axis.
Steven Lord 2024 年 5 月 21 日 15:10
You can show the text "1e-2000" on the axes.
plot(1, 1, 'o')
xticks(1)
xticklabels('1e-2000')
But as Walter stated, you cannot represent 1e-2000 as a double precision number. It underflows to 0. If you can't represent it as a double precision number, you can't plot it.
x = 1e-2000 % underflow
x = 0
x == 0 % x is exactly, down to the last bit, zero
ans = logical
1
figure
h = plot(x, 1, '+');
h.XData % exactly zero
ans = 0

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by