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

조회 수: 1 (최근 30일)
Kasmita Devi
Kasmita Devi 2024년 5월 21일
댓글: Steven Lord 2024년 5월 21일
set(gca, 'YScale', 'log')
ylim ([0 1e-308])
Instead of 1e-308 i want 1e-2000. how can i set the limit plz

채택된 답변

Hassaan
Hassaan 2024년 5월 21일
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
ylim([10^-2000, 10^2]); % Adjust according to the range of your data
-----------------------------------------------------------------------------------------------------------------------------------------------------
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개)

Walter Roberson
Walter Roberson 2024년 5월 21일
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
Kasmita Devi
Kasmita Devi 2024년 5월 21일
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
Steven Lord 2024년 5월 21일
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 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