How should I plot the CDF for another parameter
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a waveform data that describes the variation of amplitude with height. I want to plot a CDF plot of the amplitude variation with height, but I have not found how it should be plotted(Just like the picture). I only found the way to plot the CDF plot of the amplitude itself.
My data is in the attachment, and code is here:
waveform=readtable(waveformLoc);
x=waveform.Elevation_m_;
y=waveform.Amplitude_DN_;
plot(x_flip,y_flip,'b'); %show the waveform
[f,x] = ecdf(y);
plot(x,f); %CDF about amplitude itself
Réponses (1)
Varun
le 8 Sep 2023
Hi Shufan,
Looks like you want to plot CDF of amplitude variation with elevation. Currently you are able to plot CDF of the amplitude with amplitude itself.
Please refer the following code snippet to plot CDF of amplitude variation with elevation:
data = readtable('Data.csv');
amplitude = data{:, 2}; % Assuming the amplitude is in the second column
elevation = data{:, 3}; % Assuming the elevation is in the third column
% Sort the amplitude values based on elevation
[sortedElevation, sortIdx] = sort(elevation);
sortedAmplitude = amplitude(sortIdx);
% Calculate the empirical CDF using ecdf
[f, x] = ecdf(sortedAmplitude);
% Plot the CDF
plot(sortedElevation, f);
xlabel('Elevation (m)');
ylabel('Cumulative Probability');
title('CDF Plot: Amplitude Variation with Elevation');
Here is the breakdown of the code:
- The code sorts the elevation values in ascending order using the “sort” function and stores the sorted values in the variable “sortedElevation”.
- The “sort” function also returns the corresponding indices of the sorted values, which are stored in the variable “sortIdx”.
- The code rearranges the amplitude values based on the sorted elevation indices using indexing, resulting in the sorted amplitudes stored in the variable “sortedAmplitude”.
- The “ecdf” function is used to calculate the empirical cumulative distribution function (CDF) of the sorted amplitude values.
- The “ecdf” function returns two outputs: ‘f’ represents the cumulative probabilities, and ‘x’ represents the corresponding amplitude values.
- Finally, a plot is generated, showing the CDF values for amplitute plotted against the elevation values with appropriate axis labels and a title.
Hope this helps.
0 commentaires
Voir également
Catégories
En savoir plus sur Matched Filter and Ambiguity Function dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!