Problem with non-Zero Matrix Appearing Zero in Command Window and in Imagesc

1 vue (au cours des 30 derniers jours)
I am generating a matrix "allpowpf" which shows the power generated as a function of wave slowness and frequency. When I double click on the matrix under the variable listing, it shows a matrix filled with numbers on the magnitude of e10 (screenshot attached). However, when I type "powpf" into the command window, it shows a matrix filled with zeros (screenshot attached). Most importantly, when I plot allpowpf using imagesc, I get an image of an array of zeros instead of the proper numbers.
I generate the zero matrix allpowpf using:
allpowpf = zeros(np,nf/2);
Then, I fill allpowpf using the following:
Y = fft(taup(k,:));
for j = 1:nf/2 % samples in frequency domain, stop at Nyquist
allpowpf(k,j) = allpowpf(k,j) + real(Y(j)^2);
end
And finally, I plot allpowpf using:
imagesc(allpowpf) % plot of energy slowness and frequency
xlabel('frequency (Hz)')
ylabel('slowness (ms/m)')
I believe that my loops are working correctly because the variable allpowpf is correct, but I do not understand why it plots as a zero matrix or why it appears in the command window as a zero matrix when it is not a zero matrix as a stored variable.

Réponse acceptée

John D'Errico
John D'Errico le 29 Fév 2024
They are still (non-zero) numbers. Just too small to display in the chosen format. If you close your eyes, the world does not disappear. ;-)
X = [123456789012345 0.00000123456789]
X = 1×2
1.0e+14 * 1.2346 0.0000
But that second element is still there. Not zero.
X(2)
ans = 1.2346e-06
You can generally force MATLAB to show the true values using a scientific display format.
format short g
X
X = 1×2
1.0e+00 * 1.2346e+14 1.2346e-06
  2 commentaires
Rose
Rose le 29 Fév 2024
Modifié(e) : Rose le 29 Fév 2024
Thank you! Do you have advice for the imagesc plot? Right now, it only plots one solid color at 0, which doesn't help me much. I need to see which frequencies and slownesses have the most power across my seismic array.
Steven Lord
Steven Lord le 29 Fév 2024
What's the range of data stored in your matrix? What do you see when you run these commands?
format longg
[minvalue, maxvalue] = bounds(allpowpf, "all")
therange = maxvalue - minvalue

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by