Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
Kasmita Devi
Kasmita Devi am 21 Mai 2024
Kommentiert: Steven Lord am 21 Mai 2024
set(gca, 'YScale', 'log')
ylim ([0 1e-308])
Instead of 1e-308 i want 1e-2000. how can i set the limit plz

Akzeptierte Antwort

Hassaan
Hassaan am 21 Mai 2024
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.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 21 Mai 2024
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 Kommentare
Kasmita Devi
Kasmita Devi am 21 Mai 2024
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 am 21 Mai 2024
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

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by