Obtaining the percentile 95 of a matrix and then plotting it3d plots in matlab based on a matrixMATLAB — How does one plot a heatmap from nxn matrix?Heatmap or plot for a correlation matrixHow to be able to plot Matrix and the mean of matrix in Matlab?Line plot of rows in a Matlab matrix with the x-axis is the maximum valueQuiver from a single matrixHow do you plot the 3-D plot for pcolor style using one matrix with varying one variable along Z-axis?redblue colormap with transition period at zeroFinding local minima about either side of a maxima in a matrix in matlabHow to rotate X Labels in MATLAB R2014a using edit tool?

What does “the session was packed” mean in this context?

How seriously should I take size and weight limits of hand luggage?

Should I tell management that I intend to leave due to bad software development practices?

Mathematica command that allows it to read my intentions

Do scales need to be in alphabetical order?

One verb to replace 'be a member of' a club

Why do bosons tend to occupy the same state?

All in one piece, we mend holes in your socks

What is a romance in Latin?

What do you call someone who asks many questions?

Size of subfigure fitting its content (tikzpicture)

Is "remove commented out code" correct English?

Why didn't Miles's spider sense work before?

How much of data wrangling is a data scientist's job?

Detention in 1997

Can my sorcerer use a spellbook only to collect spells and scribe scrolls, not cast?

What killed these X2 caps?

Could the museum Saturn V's be refitted for one more flight?

Venezuelan girlfriend wants to travel the USA to be with me. What is the process?

Is it inappropriate for a student to attend their mentor's dissertation defense?

Watching something be piped to a file live with tail

Assassin's bullet with mercury

Can we compute the area of a quadrilateral with one right angle when we only know the lengths of any three sides?

Why is this clock signal connected to a capacitor to gnd?



Obtaining the percentile 95 of a matrix and then plotting it


3d plots in matlab based on a matrixMATLAB — How does one plot a heatmap from nxn matrix?Heatmap or plot for a correlation matrixHow to be able to plot Matrix and the mean of matrix in Matlab?Line plot of rows in a Matlab matrix with the x-axis is the maximum valueQuiver from a single matrixHow do you plot the 3-D plot for pcolor style using one matrix with varying one variable along Z-axis?redblue colormap with transition period at zeroFinding local minima about either side of a maxima in a matrix in matlabHow to rotate X Labels in MATLAB R2014a using edit tool?













1















EDIT:
I have been asked to add more detail. Originally I have a 360x180 matrix, and in it there are data of E-P values, these values stand for Evaporation (E) and Precipitation (P), and they basically indicate sources (E-P>0) and sinks(E-P<0) of moisture. In order to obtain the most important sources of moisture I have to take only the positive values, and I want to obtain the percentile 95 of these values, then plot the values which are above this threshold, since I wanted to do a reproducible example I used the peaks data:



I have done this in MATLAB but if it can be made on R it works for me as well.



I have an example 49x49 matrix like this:



a = peaks; 
pcolor(a);
caxis([-10 10]);
cbh=colorbar('v');
set(cbh,'YTick',(-10:1:10))


And it shows something like this enter image description here



What I want to do is to obtain the percentile 95 of only the positive values, and then plotting them.



How can I do this? and also, what would it be better: To replace all the values less than zero with 0's or Nan's??










share|improve this question
























  • I have added more detail, hopping that it makes it more clear.

    – Ann M
    Mar 9 at 23:31











  • I think the question is clear now, voting to reopen.

    – Cris Luengo
    Mar 10 at 0:15















1















EDIT:
I have been asked to add more detail. Originally I have a 360x180 matrix, and in it there are data of E-P values, these values stand for Evaporation (E) and Precipitation (P), and they basically indicate sources (E-P>0) and sinks(E-P<0) of moisture. In order to obtain the most important sources of moisture I have to take only the positive values, and I want to obtain the percentile 95 of these values, then plot the values which are above this threshold, since I wanted to do a reproducible example I used the peaks data:



I have done this in MATLAB but if it can be made on R it works for me as well.



I have an example 49x49 matrix like this:



a = peaks; 
pcolor(a);
caxis([-10 10]);
cbh=colorbar('v');
set(cbh,'YTick',(-10:1:10))


And it shows something like this enter image description here



What I want to do is to obtain the percentile 95 of only the positive values, and then plotting them.



How can I do this? and also, what would it be better: To replace all the values less than zero with 0's or Nan's??










share|improve this question
























  • I have added more detail, hopping that it makes it more clear.

    – Ann M
    Mar 9 at 23:31











  • I think the question is clear now, voting to reopen.

    – Cris Luengo
    Mar 10 at 0:15













1












1








1








EDIT:
I have been asked to add more detail. Originally I have a 360x180 matrix, and in it there are data of E-P values, these values stand for Evaporation (E) and Precipitation (P), and they basically indicate sources (E-P>0) and sinks(E-P<0) of moisture. In order to obtain the most important sources of moisture I have to take only the positive values, and I want to obtain the percentile 95 of these values, then plot the values which are above this threshold, since I wanted to do a reproducible example I used the peaks data:



I have done this in MATLAB but if it can be made on R it works for me as well.



I have an example 49x49 matrix like this:



a = peaks; 
pcolor(a);
caxis([-10 10]);
cbh=colorbar('v');
set(cbh,'YTick',(-10:1:10))


And it shows something like this enter image description here



What I want to do is to obtain the percentile 95 of only the positive values, and then plotting them.



How can I do this? and also, what would it be better: To replace all the values less than zero with 0's or Nan's??










share|improve this question
















EDIT:
I have been asked to add more detail. Originally I have a 360x180 matrix, and in it there are data of E-P values, these values stand for Evaporation (E) and Precipitation (P), and they basically indicate sources (E-P>0) and sinks(E-P<0) of moisture. In order to obtain the most important sources of moisture I have to take only the positive values, and I want to obtain the percentile 95 of these values, then plot the values which are above this threshold, since I wanted to do a reproducible example I used the peaks data:



I have done this in MATLAB but if it can be made on R it works for me as well.



I have an example 49x49 matrix like this:



a = peaks; 
pcolor(a);
caxis([-10 10]);
cbh=colorbar('v');
set(cbh,'YTick',(-10:1:10))


And it shows something like this enter image description here



What I want to do is to obtain the percentile 95 of only the positive values, and then plotting them.



How can I do this? and also, what would it be better: To replace all the values less than zero with 0's or Nan's??







r matlab statistics quantile






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 23:30







Ann M

















asked Mar 8 at 22:39









Ann MAnn M

9610




9610












  • I have added more detail, hopping that it makes it more clear.

    – Ann M
    Mar 9 at 23:31











  • I think the question is clear now, voting to reopen.

    – Cris Luengo
    Mar 10 at 0:15

















  • I have added more detail, hopping that it makes it more clear.

    – Ann M
    Mar 9 at 23:31











  • I think the question is clear now, voting to reopen.

    – Cris Luengo
    Mar 10 at 0:15
















I have added more detail, hopping that it makes it more clear.

– Ann M
Mar 9 at 23:31





I have added more detail, hopping that it makes it more clear.

– Ann M
Mar 9 at 23:31













I think the question is clear now, voting to reopen.

– Cris Luengo
Mar 10 at 0:15





I think the question is clear now, voting to reopen.

– Cris Luengo
Mar 10 at 0:15












1 Answer
1






active

oldest

votes


















0














If you have the statistics toolbox, you can use the function prctile to obtain a percentile. I don't have this toolbox, so I wrote my own version (a long time ago) based on the code for the function median. With either prctile or percentile you can do:



a = peaks;
t = percentile(a(a>0),95);
b = a > t;

subplot(1,2,1)
pcolor(a);
subplot(1,2,2)
pcolor(b);


a(a>0) is a vector with all the positive values in a. t is the 95th percentile of this vector.



output of code above






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55071984%2fobtaining-the-percentile-95-of-a-matrix-and-then-plotting-it%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    If you have the statistics toolbox, you can use the function prctile to obtain a percentile. I don't have this toolbox, so I wrote my own version (a long time ago) based on the code for the function median. With either prctile or percentile you can do:



    a = peaks;
    t = percentile(a(a>0),95);
    b = a > t;

    subplot(1,2,1)
    pcolor(a);
    subplot(1,2,2)
    pcolor(b);


    a(a>0) is a vector with all the positive values in a. t is the 95th percentile of this vector.



    output of code above






    share|improve this answer



























      0














      If you have the statistics toolbox, you can use the function prctile to obtain a percentile. I don't have this toolbox, so I wrote my own version (a long time ago) based on the code for the function median. With either prctile or percentile you can do:



      a = peaks;
      t = percentile(a(a>0),95);
      b = a > t;

      subplot(1,2,1)
      pcolor(a);
      subplot(1,2,2)
      pcolor(b);


      a(a>0) is a vector with all the positive values in a. t is the 95th percentile of this vector.



      output of code above






      share|improve this answer

























        0












        0








        0







        If you have the statistics toolbox, you can use the function prctile to obtain a percentile. I don't have this toolbox, so I wrote my own version (a long time ago) based on the code for the function median. With either prctile or percentile you can do:



        a = peaks;
        t = percentile(a(a>0),95);
        b = a > t;

        subplot(1,2,1)
        pcolor(a);
        subplot(1,2,2)
        pcolor(b);


        a(a>0) is a vector with all the positive values in a. t is the 95th percentile of this vector.



        output of code above






        share|improve this answer













        If you have the statistics toolbox, you can use the function prctile to obtain a percentile. I don't have this toolbox, so I wrote my own version (a long time ago) based on the code for the function median. With either prctile or percentile you can do:



        a = peaks;
        t = percentile(a(a>0),95);
        b = a > t;

        subplot(1,2,1)
        pcolor(a);
        subplot(1,2,2)
        pcolor(b);


        a(a>0) is a vector with all the positive values in a. t is the 95th percentile of this vector.



        output of code above







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 11 at 6:25









        Cris LuengoCris Luengo

        22.5k52253




        22.5k52253





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55071984%2fobtaining-the-percentile-95-of-a-matrix-and-then-plotting-it%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

            2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

            Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme