Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6748841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:36:56+00:00 2026-05-26T12:36:56+00:00

I have 2 example vector in Matlab : A = [5,3,3,0,4,1,5,0,2,5,5,0,5,3,4,0,1,4,4,0,4,2]; B = [1,0,0,0,1,0,4,0,0,0,0,4,4,0,1,0,0,0,0,0,0,0];

  • 0

I have 2 example vector in Matlab :

A = [5,3,3,0,4,1,5,0,2,5,5,0,5,3,4,0,1,4,4,0,4,2];
B = [1,0,0,0,1,0,4,0,0,0,0,4,4,0,1,0,0,0,0,0,0,0];

When, I try to calculate pearson correlation with manual method and do it with excel
I have the same result (0.667)

1 0,667
0,667 1

But when I tried in MatLab with simple code:

pearson = corr(A',B');

it return the result with different score (0,2139).

1 0,2139
0,2139 1

Maybe Its happen because the zero score(0) is using to calculate it. In happen because the missing value will be replace by zero(0) in matlab.

In Pearson Correlation that only use co-rated value to calculate it. (see the bold value)

A = [5,3,3,0,4,1,5,0,2,5,5,0,5,3,4,0,1,4,4,0,4,2];
B = [1,0,0,0,1,0,4,0,0,0,0,4,4,0,1,0,0,0,0,0,0,0];

or it can make simple :

A = [5,4,5,5,4];
B = [1,1,4,4,1];

Does anyone know, how to make simple code for this?
I have try it in procedural code :
first, make function corated, average_corated, then at last calculate similarity.
it cost too much time.

Thanks before 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:36:57+00:00Added an answer on May 26, 2026 at 12:36 pm

    You have to get the index for where the good data is located first:

    goodData = A~=0 & B~=0; %# true wherever there's data for both A and B
    
    pearson = corr(A(goodData),B(goodData));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a vector for example a = [0 1 0 3] I want
What I would like to do (in Clojure): For example, I have a vector
I'm wondering if it's possible if you have, for example, a vector<string> and a
I have example.org and foo.example.org pointing to the same directory, /var/www/html/ , and want
I have a linspace vector in matlab, a vector of eigenvalues and a matrix
I have this example code that doesn't compile: #include <iostream> #include <vector> using std::endl;
I am using Matlab, and I have a 1x200 vector of numbers. I need
I have example of code below. <script type=text/javascript src=assets/scripts/somescript.php>. </script> So, will my browser
Anyone have example Rx code that shows how to execute an action due to
I have example: for line in IN.readlines(): line = line.rstrip('\n') mas = line.split('\t') row

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.